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

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

Asked by 10 years ago

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!

Closed as Not Constructive by Goulstem, Shawnyg, and M39a9am3R

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

3 answers

Log in to vote
0
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

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.

Ad
Log in to vote
0
Answered by 10 years ago

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

Log in to vote
-1
Answered by 10 years ago
--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)