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

Why doesn't this elevator script work? (PrimaryPartCFrame)

Asked by 4 years ago
local C1 = script.Parent.Parent.Parent.Pos2.CFrame.Position.Y - script.Parent.Parent.Parent.Pos1.CFrame.Position.Y

script.Parent.Parent.Parent.Clicker.ClickDetector.MouseClick:Connect(function()
    for i = script.Parent.Parent.Parent.Pos1.CFrame.Position.Y, C1, 0.1  do
        wait(0.1)
        script.Parent.Parent:SetPrimaryPartCFrame(CFrame.new(script.Parent.Parent.PrimaryPart.Position.X, i, script.Parent.Parent.PrimaryPart.Position.Z ))
    end
end)

Im not quite sure why this doesn't work, it is rotating the opposite direction, even though I specified POSITION, and moves the same speed, even if I change the wait() time in the for loop.

2
You really need to use variables, after that many parents, how will you be sure what is what? SteamG00B 1633 — 4y
0
Also, why don't you use the tween service instead? https://developer.roblox.com/en-us/api-reference/class/TweenService SteamG00B 1633 — 4y

Answer this question