Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does "table.find()" returns a nil value inside of a table of players?

Asked by 3 years ago

I am trying to find the index value of Hit.Parent, inside of a list of players. However, it returns me nil instead of the index value.

local Players = game.Players:GetChildren()
RedSide.Touched:Connect(function(Hit)
    print(table.find(Players,Hit.Parent))
end)

Any ideas on how to get the index value of this working properly?

Thanks!

0
Hit.Parent, in this context, refers to the Character, not the Player Object. Use Players:GetPlayerFromCharacter(Hit.Parent) instead. Ziffixture 6913 — 3y
0
Also, Players:GetPlayers()** Ziffixture 6913 — 3y
0
Thanks! ChickwensRule 2 — 3y

Answer this question