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

Elevator Door Won't Open? [RemoveEvents Involved]

Asked by
Rothia 25
8 years ago

After figuring out about my last issue with the doors (FilteringEnabled being on), I've decided to attempt using RemoveEvents as a means to keep FilteringEnabled on and allow it to work. That being said, I've found my attempts at it are failing. Are there any issues I'm not noticing, or being told by ROBLOX Studio?

Server Script

-- Inside Server Script
local Door1 = script.Parent.Parent:WaitForChild("Door1")
local Door2 = script.Parent.Parent:WaitForChild("Door2")
local bell = script.Parent.Parent.Ceiling:WaitForChild("Bell")
local event = game.Workspace.Elevator1Function
event.OnServerEvent:connect(function(onClicked) -- define the function that will be called when the event is fired
    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)
        bell:play()
        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 -- this is where you put all the code you want to run when the event is fired
end)

Local Script

-- Inside Local Script
local clickDetector = script.Parent:WaitForChild("ClickDetector")
clickDetector.MouseClick:connect(function(onClicked)
    game.Workspace.Elevator1Function:FireServer()
end)

1 answer

Log in to vote
0
Answered by 8 years ago

LocalScripts only run in certain places
Elephants also really hate mice.

You can't make a LocalScript run in Workspace except for in some very specific circumstances. As a result, you'll need to put the LocalScript in StarterPlayerScripts and try to statically access the Instance that clickDetector would otherwise point to.

Ad

Answer this question