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

How to solve issue with CFraming a Model when using wait() in the for loop?

Asked by 5 years ago

Been testing out a way to make a lift using CFrames: lua --Variable for the parts of the model. Platform = script.Parent.Parent:GetChildren() --Function that runs when you click it. script.Parent.ClickDetector.MouseClick:Connect(function() --Iteration through the parts of the model. for key, value in pairs(Platform) do --Basic for loop. for i = 1, 100 do --Waits so the CFrame isnt a teleport. wait(0.001) --Basic CFrame script. value.CFrame = value.CFrame * CFrame.new(0,0.1,0) end end end) Without the wait all the parts in the Lift Model teleport to the new CFrame position as expected.

The issue is with the wait in place only one object is moved up at a time, which is obviously not want you want when making a lift. However I cannot delete the wait as then its a teleporter not a lift.

Any solutions for how I can still include a wait but move all objects at the same time would be great.

Answer this question