|
| 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
|
  |
| Joined: 16 Oct 2007 |
| Total Posts: 16381 |
|
|
| 12 Sep 2013 08:57 PM |
a,b=Return() print(a)
> true
print(b)
> 1 |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 16 Oct 2007 |
| Total Posts: 16381 |
|
|
| 12 Sep 2013 09:02 PM |
| you can't set true and false as variables |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|