RogueMage
|
  |
| Joined: 28 Jan 2012 |
| Total Posts: 1235 |
|
|
| 23 Dec 2016 06:27 PM |
If I have said function:
function _M.findData(player) -- returns boolean to check if the we could find the player data if player then if game.ReplicatedStorage.PlayerData:FindFirstChild(player.UserId .. "_data") then return true, game.ReplicatedStorage.PlayerData:FindFirstChild(player.UserId .. "_data") else return false end else return false end end
and then I try to assign it to variables, such that:
local check, folder = _M.findData(player)
If I return false for check, then I wouldn't be returning *folder*
Would that just evaluate to nil? |
|
|
| Report Abuse |
|
|
OAuth2
|
  |
| Joined: 27 Nov 2016 |
| Total Posts: 751 |
|
|
| 23 Dec 2016 06:33 PM |
return val1, val2
~ This is not a siggy ~ |
|
|
| Report Abuse |
|
|
RogueMage
|
  |
| Joined: 28 Jan 2012 |
| Total Posts: 1235 |
|
|
| 23 Dec 2016 06:36 PM |
I'm not asking how to return multiple values...
Read what I asked |
|
|
| Report Abuse |
|
|
SteadyOn
|
  |
| Joined: 20 Mar 2011 |
| Total Posts: 600 |
|
|
| 23 Dec 2016 06:37 PM |
You're defining 2 values but only returning one, therefore it's only registering check as false and doing nothing for folder.
do what he said ^
- R$389 SteadyOn if u wanna thank me buy this 4 5 r$ www.roblox.com/catalog/446657116/Ayy-Lmao |
|
|
| Report Abuse |
|
|
clc02
|
  |
| Joined: 30 Dec 2007 |
| Total Posts: 7393 |
|
|
| 23 Dec 2016 06:38 PM |
Alternatively return {Item = game.Workspace.Item, Player = game.Players.Player, Target = game.Workspace.Target}
results = func() results.Item:Destroy() results.Player.Score.Value = results.Player.Score.Value + 1 results.Target:Destroy()
I prefer it to return one, two as you'll never go "Well, do I go item, player, target = func() or was it player, target, item = func()" |
|
|
| Report Abuse |
|
|
OAuth2
|
  |
| Joined: 27 Nov 2016 |
| Total Posts: 751 |
|
|
| 23 Dec 2016 06:39 PM |
My bad. Yes, folder will return nil.
~ This is not a siggy ~ |
|
|
| Report Abuse |
|
|
SteadyOn
|
  |
| Joined: 20 Mar 2011 |
| Total Posts: 600 |
|
|
| 23 Dec 2016 06:39 PM |
Oh I see. I mean I don't really see the point in it unless you're planning on giving 2 variables in one place and 1 in another. I'm not sure but it's likely that only check is being filled.
If you want to avoid glitches just define it as nil
so like
return false, nil
- R$389 SteadyOn if u wanna thank me buy this 4 5 r$ www.roblox.com/catalog/446657116/Ayy-Lmao |
|
|
| Report Abuse |
|
|
OAuth2
|
  |
| Joined: 27 Nov 2016 |
| Total Posts: 751 |
|
|
| 23 Dec 2016 06:41 PM |
@SteadyOn "If you want to avoid glitches just define it as nil"
Incorrect. There will be no glitches as folder will automatically be nil.
local a,b = 3 print(a, b)
> 3 nil
~ This is not a siggy ~ |
|
|
| Report Abuse |
|
|
SteadyOn
|
  |
| Joined: 20 Mar 2011 |
| Total Posts: 600 |
|
|
| 23 Dec 2016 06:42 PM |
I meant it as a precaution as I don't really know whether it would return nil, as you have now pointed out it would return as nil.
- R$389 SteadyOn if u wanna thank me buy this 4 5 r$ www.roblox.com/catalog/446657116/Ayy-Lmao |
|
|
| Report Abuse |
|
|