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

How do I make the door close after it's been opened?

I'm trying to make a clickable door, and I've made it so it's rotated open with this script:

game.Workspace.Door.Script.Name = "Clickable Door Script"
script.Parent.ClickDetector.MouseClick:connect(function()
game.Workspace.Door.Rotation = Vector3.new(0,3,0)
end)

I want to make it able to close if you click it again.

1 answer

✓ Accepted answer

You would use a simple variable to check if it has been opened or not.

local open = false;

script.Name = "Clickable Door Script"; -- On the assumption that this is that script

script.Parent.ClickDetector.MouseClick:connect(function()

	if not open then -- Checks if closed

		script.Parent.Rotation = Vector3.new(0, 3, 0);

		open = true;

	else -- If open

		script.Parent.Rotation = Vector3.new(0, 0, 0);

		open = false;

	end

end)

7 comments

0

Thank you!

0

Wait, it's still not working?

0

Is the script inside of the part?

0

I edited it. It wouldn't work if there was more than one door before.

0

There isn't. I'm only working on one

0

And, yes, the script is inside of the part.

0

Thank you! :)

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