|
| 26 Sep 2013 01:15 PM |
so im making a button that when you step on it it opens the door for three seconds then closes. it opens the door alright, but i tdoesnt close after 3 seconds... here it is...
door1 = Workspace.door1 local enabled = true Workspace.pp1.Touched:connect(function(hit) if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) and enabled == true then door1.Transparency = 1 door1.cancollide = false wait (3) door1.Transparency = 0 door1.cancollide = true end end) |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2013 01:23 PM |
door1 = Workspace.door1 local enabled = true Workspace.pp1.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid")and enabled then enabled = false door1.Transparency = 1 door1.CanCollide = false wait (3) door1.Transparency = 0 door1.CanCollide = true enabled = true end end) |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2013 02:10 PM |
Huge, I know why. You had a space between "wait" and your opening bracket. Don't do that.
Fixed:
door1 = Workspace.door1 local enabled = true Workspace.pp1.Touched:connect(function(hit) if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) and enabled == true then door1.Transparency = 1 door1.cancollide = false wait(3) door1.Transparency = 0 door1.cancollide = true end end)
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
takecover
|
  |
| Joined: 19 Jun 2009 |
| Total Posts: 407 |
|
|
| 26 Sep 2013 03:03 PM |
| Got the capitalization of CanCollide wrong. |
|
|
| Report Abuse |
|
|
|
| 26 Sep 2013 03:32 PM |
Okay, totally fixed version:
door1 = Workspace.door1 local enabled = true Workspace.pp1.Touched:connect(function(hit) if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) and enabled == true then door1.Transparency = 1 door1.CanCollide = false wait(3) door1.Transparency = 0 door1.CanCollide = true end end)
【◄[ϟ]〓☜✪ xWOWZABOYx; FCOM, SQN COM, Scientist, Veteran, Visionary ✪☞〓[ϟ]►】 |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 26 Sep 2013 03:51 PM |
xWOWZABOYx, you can have spaces after functions and the calls for them.
Lua allows you to write your scripts almost vertically. |
|
|
| Report Abuse |
|
|