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

Elevator Fails to Open in Servers?

Asked by
Rothia 25
8 years ago

I use the script below in a button to open a two-door elevator, which the doors move in the same direction. It works as intended in test servers (which seems to be a theme that runs through my questions), but in an active server, it fails to operate. The Click Detector noted is in the correct placement, and there is nothing else for the script to do. Any reason why it may be acting up?

-- Door variables
local Button = script.Parent
local Door1 = script.Parent.Parent.Door1
local Door2 = script.Parent.Parent.Door2

function onClicked()
    wait(3)
    for e = 2,25 do
        Door1.CFrame = CFrame.new(Door1.CFrame.x,Door1.CFrame.y,Door1.CFrame.z - 0.15)
        Door2.CFrame = CFrame.new(Door2.CFrame.x,Door2.CFrame.y,Door2.CFrame.z - 0.3)
        wait(.0001)
    end
    wait(5)
    for e = 2,25 do
        Door1.CFrame = CFrame.new(Door1.CFrame.x,Door1.CFrame.y,Door1.CFrame.z + 0.15)
        Door2.CFrame = CFrame.new(Door2.CFrame.x,Door2.CFrame.y,Door2.CFrame.z + 0.3)
        wait(.0001)
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
0
I'm not entirely sure what's wrong here, but most of the time (at least for me), the reason why a script works in Studio and not in-game is because there's no delay at the beginning of the script. Try putting a 'wait()' for a couple seconds at the beginning of the script. nilVector 812 — 8y

Answer this question