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

Cylinder part rotates when CFrame script activates. How do I fix this?

Asked by 5 years ago

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!

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)
0
So I put in the script. It worked. But the player is still at the bottom. The part teleported. While the player stayed below. Yutube_SB101 5 — 5y
0
 So you want it to move the player? If so, you need to increase the both 30's, to lets say... 200. Then place a wait below line 8. I can update my answer if that helps? Stephenthefox 94 — 5y
0
Yea Im still very new to scripting. Please update if possible. Thanks for helping me Yutube_SB101 5 — 5y
0
Now the part just disappears. Should I make a video and send a link to show you? Yutube_SB101 5 — 5y
View all comments (3 more)
0
Uh sure, because it shouldn't disappear. Nothing changed but the amount of loops it does. Stephenthefox 94 — 5y
0
Try that Stephenthefox 94 — 5y
Ad

Answer this question