Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

how do I make the size of a part become x if the size of that part is y?

Asked by
lytew 99
4 years ago

how do I make the size of a part become x if the size of that part is y? for example: If the size of the size is equal to 10,10,10 then part size = 5.5.5 can anyone help?

2 answers

Log in to vote
0
Answered by 4 years ago

This is actually a pretty basic situation, just use Vector3.

For this example I will assume the part is the parent, if it isn't, this still works.

local sp =  script.Parent -- in this case, the parent of the script is the part.

if sp.Size == Vector3.new(1,1,1) then
    sp.Size = Vector3.new(5,5,5)
end
Ad
Log in to vote
0
Answered by 4 years ago

Part 1: You can do this by changing the Size property of the part. Example:

n = workspace.Part
local sizeVar = n.Size
n.Size = Vector3.new(5,5,5) -- Changing Size uses Vector3

Now we'll check if the size is 10,10,10 before doing so.

n = workspace.Part
local sizeVar = n.Size
if n.Size == Vector3.new(10,10,10) then
    n.Size = Vector3.new(5,5,5) -- Changing Size uses Vector3
end

Now if the size is not 10, 10, 10 then nothing will happen. You can also use math to change the size.

n = workspace.Part
local sizeVar = n.Size
if n.Size == Vector3.new(10,10,10) then
    n.Size = Vector3.new(sizeVar.X / 2, sizeVar.X / 2, sizeVar.Z/ 2) -- Changing Size uses Vector3
end

Answer this question