Hello, my game has a max of 8 players. I need to have a script that assigns a number value to each player. I know how to put a value into a player and know when they disconnect and join, but I just dont know how to give each other them their own number.
for example, player 1 = number 1, player 2 = number 2 and on and on
Thank you
You could simply use GetPlayers()
to do this.
game.Players:GetPlayers()[3] --> this will fetch player 3's player object, if there are that many players.
Here's the rest of the script.
function tpAllPlayers() for i,v in pairs(game.Players:GetPlayers()) do if workspace[game.Players:GetPlayers()[i].Name] then workspace[game.Players:GetPlayers()[i].Name].HumanoidRootPart.CFrame = workspace:FindFirstChild("Spawn" .. i).CFrame end end end
Now player 2 will be teleported to an object named "Spawn2" in this case.