hung999
|
  |
| Joined: 19 Sep 2008 |
| Total Posts: 819 |
|
|
| 04 Feb 2012 04:23 PM |
script.Parent.MouseButton1Down:connect(function(click) local door = game.Workspace:FindFirstChild("SomeDoor") if script.Parent.Toggled == 1 then for i = 1, 70 do door.CFrame = door.CFrame*CFrame.new(0.1, 0, 0) wait() end return click if script.Parent.Toggled == 0 then for i = 1, 70 do door.CFrame = door.CFrame*CFrame.new(-0.1, 0, 0) wait() end end end)
15:22:47 - Players.Player.PlayerGui.ScreenGui.Frame.Open.Script:9: 'end' expected (to close 'if' at line 3) near 'if' 15:22:47 - Players.Player.PlayerGui.ScreenGui.Frame.Open.Script:9: 'end' expected (to close 'if' at line 3) near 'if' |
|
|
| Report Abuse |
|
|
|
| 04 Feb 2012 04:25 PM |
" return click if script.Parent.Toggled == 0 then"
Bad. You cannot have code after a return that is within the same scope level as the return itself. |
|
|
| Report Abuse |
|
|
|
| 04 Feb 2012 04:25 PM |
script.Parent.MouseButton1Down:connect(function(click) local door = game.Workspace:FindFirstChild("SomeDoor") if script.Parent.Toggled == 1 then for i = 1, 70 do door.CFrame = door.CFrame*CFrame.new(0.1, 0, 0) wait() end return click end if script.Parent.Toggled == 0 then for i = 1, 70 do door.CFrame = door.CFrame*CFrame.new(-0.1, 0, 0) wait() end end end) |
|
|
| Report Abuse |
|
|
|
| 04 Feb 2012 04:26 PM |
> Bad. You cannot have code after a return that is within the same scope level as the return itself.
I'm pretty sure you can... |
|
|
| Report Abuse |
|
|
hung999
|
  |
| Joined: 19 Sep 2008 |
| Total Posts: 819 |
|
|
| 04 Feb 2012 04:28 PM |
| The only problem kingkiller is that the "SomeDoor" doesn't slide , and there is no error in output anyways . By the way thanks guys ! I've learnt many things from this Roblox Category . |
|
|
| Report Abuse |
|
|
C0D3Y
|
  |
| Joined: 24 Jul 2010 |
| Total Posts: 1692 |
|
|
| 04 Feb 2012 04:41 PM |
script.Parent.MouseButton1Down:connect(function(click) local door = game.Workspace:FindFirstChild("SomeDoor") if script.Parent.Toggled == 1 then for i = 1, 70 do door.CFrame = door.CFrame*CFrame.new(0.1, 0, 0) wait() end return click elseif script.Parent.Toggled == 0 then for i = 1, 70 do door.CFrame = door.CFrame*CFrame.new(-0.1, 0, 0) wait() end end end)
See if that works |
|
|
| Report Abuse |
|
|
|
| 04 Feb 2012 04:51 PM |
"> Bad. You cannot have code after a return that is within the same scope level as the return itself.
I'm pretty sure you can..."
You CANNOT. It is invalid Lua code, as well as invalid in any other language. The keywords are same scope.
function a() if true then return 1 print "done" end end
^^^ invalid
function a() if true then return 1 end print "done" end
^^^ valid |
|
|
| Report Abuse |
|
|