jager72
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 11034 |
|
|
| 21 Aug 2014 08:58 PM |
I made a handicap door, but when you click the button, the door opens, but you have to click it again to close it. I need help making it so that after waiting 5 seconds, it closes by itself again. Here is the script:
door = script.Parent.Parent.Union handicap = script.Parent open = false handicap.ClickDetector.MouseClick:connect(function() if(open == false) then game.Workspace.RightHandicapDoor.DoorRotation.Part.CFrame= CFrame.new(160.28,7.19, -73.25) * CFrame.Angles(0, math.pi, 0)
game.Workspace.RightHandicapDoor.DoorRotation.Union.CFrame= CFrame.new(160.28, 7.19, -73.25) * CFrame.Angles(0, math.pi/2, 0) open = true elseif(open == true) then game.Workspace.RightHandicapDoor.DoorRotation.Part.CFrame= CFrame.new(158.28, 7.19, -71.25) * CFrame.Angles(0, math.pi/2, 0) game.Workspace.RightHandicapDoor.DoorRotation.Union.CFrame= CFrame.new(158.28, 7.19, -71.25) * CFrame.Angles(0, math.pi, 0) open = false end end) |
|
|
| Report Abuse |
|
|
jager72
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 11034 |
|
|
| 21 Aug 2014 09:00 PM |
Sorry, i screwed up the script
here it is door = script.Parent.Parent.DoorRotation handicap = script.Parent open = false handicap.ClickDetector.MouseClick:connect(function() if(open == false) then game.Workspace.RightHandicapDoor.DoorRotation.Part.CFrame= CFrame.new(164.77, 7.39, -66.22) * CFrame.Angles(0, math.pi, 0) game.Workspace.RightHandicapDoor.DoorRotation.Union.CFrame= CFrame.new(164.77, 7.39, -66.22) * CFrame.Angles(0, math.pi, 0) open = true elseif(open == true) then game.Workspace.RightHandicapDoor.DoorRotation.Part.CFrame= CFrame.new(162.77, 7.39, -64.22) * CFrame.Angles(0, math.pi/2, 0) game.Workspace.RightHandicapDoor.DoorRotation.Union.CFrame= CFrame.new(162.77, 7.39, -64.22) * CFrame.Angles(0, math.pi/2, 0) open = false end end) |
|
|
| Report Abuse |
|
|
|
| 21 Aug 2014 09:06 PM |
door = script.Parent.Parent.DoorRotation handicap = script.Parent open = false
handicap.ClickDetector.MouseClick:connect(function() if not open then open = true game.Workspace.RightHandicapDoor.DoorRotation.Part.CFrame= CFrame.new(164.77, 7.39, -66.22) * CFrame.Angles(0, math.pi, 0) game.Workspace.RightHandicapDoor.DoorRotation.Union.CFrame= CFrame.new(164.77, 7.39, -66.22) * CFrame.Angles(0, math.pi, 0) wait(5) game.Workspace.RightHandicapDoor.DoorRotation.Part.CFrame= CFrame.new(162.77, 7.39, -64.22) * CFrame.Angles(0, math.pi/2, 0) game.Workspace.RightHandicapDoor.DoorRotation.Union.CFrame= CFrame.new(162.77, 7.39, -64.22) * CFrame.Angles(0, math.pi/2, 0) open = false end end) |
|
|
| Report Abuse |
|
|
jager72
|
  |
| Joined: 14 Aug 2010 |
| Total Posts: 11034 |
|
|
| 21 Aug 2014 09:12 PM |
| I've tried that, and it opens the door, but it never closes even if I click the button again. |
|
|
| Report Abuse |
|
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
|
| 21 Aug 2014 09:23 PM |
Don't know exactly (because I don't use click detector), but I have found some other problems. You can replace CFrame.new(x,y,z) with CFrame.new(part.Position) if you plan on having several other doors, so you don't have to constantly type in the door's Position in the script. I don't know the functions of Part and Union, but at least two parts should be present: A 'hinge' part at the edge of the door and the actual door. The door should be welded to the hinge and only the hinge should rotate. If you directly change the CFrame, the rotation will be instantaneous. You should use something like BodyGyro instead (only in the hinge part)
I have built doors that open up on contact, forces the player through it (realistically), and then closes. |
|
|
| Report Abuse |
|
|
ZQFMGB12
|
  |
| Joined: 07 Aug 2010 |
| Total Posts: 208 |
|
|
| 21 Aug 2014 09:24 PM |
| Also, you should have a variable that stores the original CFrame of the door. The door's CFrame should be equal to that variable when the door closes. |
|
|
| Report Abuse |
|
|