|
| 12 Feb 2016 01:13 PM |
I have a script that picks a player based on a numbervalue in a folder called Stuff, the number value is called weight.
local Pick = 0 local ChosenPlayer = nil
function PickPlayer() Pick = 0 for _,player in pairs(game.Players:GetChildren()) do local weight = player.Stuff.Weight if weight and weight.Value > Pick then Pick = weight ChosenPlayer = Pick.Parent.Parent IncreaseWeights(Pick.Parent.Parent) end end return ChosenPlayer end
this is how I select the player
local Selected = PickPlayer()
I get the same issue though, attempt to compare userdata with number |
|
|
| Report Abuse |
|
|
| |
|
rvox
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 5380 |
|
| |
|
|
| 12 Feb 2016 01:23 PM |
| yeah saw that, thanks a ton though. |
|
|
| Report Abuse |
|
|
|
| 12 Feb 2016 01:25 PM |
Oh, I would suppose your problem is that line near the middle:
if weight and weight.Value > Pick then Pick = weight ---- The next time the loop cycles through, it will compare the next player's weight.Value with Pick, which is now the last player's Weight instance, not a number.
So to fix it, change that "Pick = weight" to:
Pick = weight.Value |
|
|
| Report Abuse |
|
|