generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Elevator Door

Previous Thread :: Next Thread 
LXXXVII is not online. 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
greedyawesomeman is not online. greedyawesomeman
Joined: 18 Apr 2010
Total Posts: 1038
19 Nov 2017 08:25 PM
What's not working in specific? When does it not work?
Report Abuse
LXXXVII is not online. LXXXVII
Joined: 13 Dec 2016
Total Posts: 14
19 Nov 2017 08:27 PM
I can get it to #### ### it wont close
Report Abuse
greedyawesomeman is not online. greedyawesomeman
Joined: 18 Apr 2010
Total Posts: 1038
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image