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?
COMMUNITY QUESTION
how do I make the size of a part become x if the size of that part is y?
2 answers
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
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
This discussion is preserved as it was. New answers, comments, and votes are closed.
