So I have a script that works fine. It's like an elevator, and ill post it below. It moves the part upwards on the Y axis. But when the script activates, the part flips itself vertically and the player falls off. How do I fix this?
lift = script.Parent.Lift game.Workspace.Ped1.Door.Sensor.Touched:Connect(function(hit) local c = hit.Parent:FindFirstChild("Humanoid") if c then for i = 1,30 do lift.CFrame = CFrame.new(lift.Position + Vector3.new(0,0.03,0)) end end end)
What the part does... https://gyazo.com/39aff9721d616f9327f5e3c625faee6d
What I want it to be orientated at... https://gyazo.com/5c1fa268f62de79024e95e1157e6ea43
Hopefully you can help me, Thanks!
There are a few ways of doing this, I would recommend Lerping, this is basically what you did but instead you calculate the end result before doing anything. For example.
lift = script.Parent.Lift game.Workspace.Ped1.Door.Sensor.Touched:Connect(function(hit) local c = hit.Parent:FindFirstChild("Humanoid") local postionYouWantItAt = CFrame.new(The CFrame Here) * CFrame.Angles(The Angle/Rotation You Wan It At Here) local speed = 200 --Increase this if you want it to go slower, decrease to go faster. The slower it is, the less it'll jump. if c then for i = 1,speed do lift.CFrame = lift.CFrame:Lerp(positionYouWantItAt,i/speed) wait() end end end)