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

How do I make a door/window open by clicking it?

I'm making a Tycoon, and I am trying to make some doors so that they look at least half decent so I was thinking, in a previous game I saw a very clever builder make windows that could be half-opened with a simple click of the mouse. I was thinking that I could do the same but with a door, and I was thinking: Is there an easy, simple way that I could build or script a door to make it open by clicking it? If there is:

  1. Please let me know.
  2. I can do the same with windows hopefully.

Thanks for reading!

3 answers

Yes, there is. Even though it is a simple script, I won't make it. To open a window with a physical part, you'd need to insert a ClickDetector into the part and have a trigger for when the event is fired (When it's clicked) in a script. To manage the event firing, you'll need a connection line and a function. The event is called MouseClick.

This is NOT a request site! Please show us some indication that you tried.

--just pretend everything is defined...

door.ClickDetector.MouseClick:connect(function()
	if  not Open then
		door.CFrame = door.CFrame * CFrame.Angles(math.rad(90), 0, 0)
		Open = false
	else
		door.CFrame = door.CFrame * CFrame.Angles(math.rad(-90), 0, 0)
		Open = true
	end
end)

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