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: Returning more than one value

Previous Thread :: Next Thread 
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
12 Sep 2013 08:57 PM
How can I make a function return more than one value?

Like...

function Return()
if true then -- Useless
return true, 1
end
end

Something like that.

return true and 1?
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
12 Sep 2013 08:57 PM
    a,b=Return()
    print(a)

> true

    print(b)

> 1
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
12 Sep 2013 09:01 PM
I'm not really sure how to use that

function abc()
true,false = Return()
end

print(
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 Sep 2013 09:01 PM
-.- this is what he means

function lol()
return true, 1
end

local Val1, Val2 = lol()
print(Val1, Val2)
>>true
>>1
Report Abuse
1waffle1 is not online. 1waffle1
Joined: 16 Oct 2007
Total Posts: 16381
12 Sep 2013 09:02 PM
you can't set true and false as variables
Report Abuse
Scriptural is not online. Scriptural
Joined: 06 Sep 2013
Total Posts: 2979
12 Sep 2013 09:06 PM
PlayersTable = {"Player1"}

function InTable(TableName,Check)
for CheckTable = 1,#TableName do
if TableName[CheckTable] == Check then
return true,CheckTable
end
end
return false,nil
end

Game.Players.PlayerAdded:connect(function(PlayerObject)
if not InTable(PlayersTable,PlayerObject.Name) then
table.insert(PlayersTable,PlayerObject.Name)
end
end)

Game.Players.PlayerLeaving:connect(function(PlayerObject)
InTableBool,TableNumber = InTable(PlayersTable,PlayerObject)
if InTableBool then
table.remove(PlayersTable,TableNumber)
end
end)


Anything wrong here?
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