setObjectScale | Multi Theft Auto: Wiki Skip to content

setObjectScale

Client-side
Server-side
Shared

Pair: getObjectScale

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function changes the visible size of an object.

Note

setObjectScale does not affect the collision models for the object, as such is unsuitable for use for interaction with players, vehicles or other objects.

OOP Syntax Help! I don't understand this!

  • Method:object:setScale(...)
  • Variable: .scale

Syntax

bool setObjectScale ( object theObject, float scale, [ float scaleY = scale, float scaleZ = scale ] )
Required Arguments
  • theObject: the object you wish to change the scale of.
  • scale: a float containing the new scale. 1.0 is the standard scale, with 0.5 being half the size and 2.0 being twice the size. If the scaleY is set, this will be scaleX.
Optional Arguments

NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.

  • scaleY (default: scale): a float containing the new scale on the Y axis
  • scaleZ (default: scale): a float containing the new scale on the Z axis

Returns

  • bool: value

This example creates an antenna, and changes the size of it.

Code Examples

shared
-- Get the position of the player
local x, y, z = getElementPosition(localPlayer)
-- Create the object
local antennaObject = createObject(1595, x + 2, y, z)
if antennaObject then -- If it was created
-- Set the scale to half the normal scale
setObjectScale(antennaObject, 0.5)
-- Remove the collision
setElementCollisionsEnabled(antennaObject, false)
end