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

Elevator goes haywire, why?

Asked by 7 years ago

So, my block of code looks like this:

local ElevatorParts = script.Parent.Parent:GetChildren()
script.Parent.ClickDetector.MouseClick:connect(function()
    if script.Parent.Parent.FloorNumber.Value < 2 then
        if script.Parent.Parent.InUse.Value == false then
            script.Parent.Parent.InUse.Value = true
            for _,v in pairs(script.Parent.Parent:GetChildren()) do
                if v.ClassName == "Part" then
                    v.CFrame = v.CFrame * CFrame.new(v.Position.X, v.Position.Y + 1, v.Position.Z)
                end
            end
        end
    end
end)

The expected output is the elevator's parts moving up one unit on the y axis, but instead turns into a black hole.

0
Because you're setting a CFrame to the current CFrame plus the CFrame of the part plus 1 of the Y Axis. To fix this, just change "* CFrame.new(v.Position.X..." with "*CFrame.new(0,1,0)" M39a9am3R 3210 — 7y
0
Whoa, thanks mate! Glueable 20 — 7y

Answer this question