LXXXVII
|
  |
| Joined: 13 Dec 2016 |
| Total Posts: 14 |
|
|
| 19 Nov 2017 08:23 PM |
I'm trying to make it where after you press the button the door opens for 2 seconds then closes automatically
I'm new to scripting please bare with me and tell me what I did wrong.
local door = script.Parent:WaitForChild("Door") local doors = script.Parent:WaitForChild("Doors")
local open = script.Parent.Open
local Debounce = false local Running = false local Open = false
open.ClickDetector.MouseClick:connect(function() if Debounce == false and Running == false and Open == false then Debounce = true Running = true Open = true for i = 1,5 do door.CFrame = door.CFrame + Vector3.new(0,0,-0.1) wait() end Running = false Debounce = false end end)
wait(2)
if Debounce == false and Running == false and Open == true then Debounce = true Running = true open = false for i = 1,5 do door.CFrame = door.CFrame + Vector3.new(0,0,-.1) wait() end end |
|
|
| Report Abuse |
|
|
|
| 19 Nov 2017 08:25 PM |
| What's not working in specific? When does it not work? |
|
|
| Report Abuse |
|
|
LXXXVII
|
  |
| Joined: 13 Dec 2016 |
| Total Posts: 14 |
|
|
| 19 Nov 2017 08:27 PM |
| I can get it to #### ### it wont close |
|
|
| Report Abuse |
|
|
|
| 19 Nov 2017 08:29 PM |
for i = 1,5 do door.CFrame = door.CFrame + Vector3.new(0,0,-.1) wait() end
You repeat the opening bit twice, if the first one opens then you have to make it go in the opposite direction (make it subtract instead of add)
local door = script.Parent:WaitForChild("Door") local doors = script.Parent:WaitForChild("Doors")
local open = script.Parent.Open
local Debounce = false local Running = false local Open = false
open.ClickDetector.MouseClick:connect(function()
if Debounce == false and Running == false and Open == false
then
Debounce = true Running = true Open = true
for i = 1,5 do door.CFrame = door.CFrame + Vector3.new(0,0,-0.1) wait()
end Running = false Debounce = false end end)
wait(2)
if Debounce == false and Running == false and Open == true
then
Debounce = true Running = true open = false
for i = 1,5 do door.CFrame = door.CFrame - Vector3.new(0,0,-.1)--edited here, but i could be wrong or it could open halfway wait() end end |
|
|
| Report Abuse |
|
|
LXXXVII
|
  |
| Joined: 13 Dec 2016 |
| Total Posts: 14 |
|
|
| 19 Nov 2017 08:33 PM |
It didn't work if you have dis add me and maybe we can figure this out together? LXXXVII #8371 if you want I'm looking for another person that's beginning their scripting career. |
|
|
| Report Abuse |
|
|