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 » Scripting Helpers
Home Search
 

Re: Help

Previous Thread :: Next Thread 
hung999 is not online. 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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
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
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
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 is not online. 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 is not online. 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
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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