Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I am trying to script an elevator door and cant get it to work. What do I do?

Here is the code. Pls respond ASAP!!

local door = script.Parent.Door

local function openelevator () door.CanCollide = false door.Transparency = .5 door.BrickColor = BrickColor.new ("Bright green") end

local function closeelevator () door.CanCollide = true door.Transparency = 0 door.BrickColor = BrickColor.new ("Black") end

while true do openelevator() wait (3) closeelevator() end

1 answer

On your while true do loop, it opens the elevator doors then it waits 3 seconds and then closes the doors and then instantly opens them. This is probably happening so fast that you don't see it actually closing. This is the fixed version.


local door = script.Parent.Door

local function openelevator() 
	door.CanCollide = false 
	door.Transparency = .5 
	door.BrickColor = BrickColor.new("Bright green")
end

local function closeelevator()
	door.CanCollide = true
	door.Transparency = 0
	door.BrickColor = BrickColor.new("Black")
end

while true do
	openelevator()
	wait(3) -- Time to wait until doors close
	closeelevator()
	wait(2) -- Time to wait for doors to open
end

This discussion is preserved as it was. New answers, comments, and votes are closed.