So, I have a script like this:
function changed(Size) local a = script.Parent.Parent.Size -- script.Parent.Parent is a part local pos = script.Parent.Parent.position.Value -- script.Parent.Parent.position is a NumberValue local value = script.Parent.Parent.Value.Value -- script.Parent.Parent.Value is a Vector3Value local x, y, z = value.x, value.y, value.z value = Vector3.new(x, (pos), z) script.Parent.Parent.CFrame = CFrame.new(value) end script.Parent.Parent.Changed:connect(changed)
So, whenever I clone an object that has this script in it, the game just freezes for 5 seconds, but I have no idea why. This script is just supposed to lower a block by a certain number of studs on the y coordinate as the position value changes. When the lag clears, the script itself works fine.
You are setting the CFrame
in your function, which then triggers the Changed
event again.
You'll want to check that anything is different before setting the CFrame
One option is to check that the parameter Size
is in fact "Size"