Hello so i'm creating a script and i'm using tables and i have to use UserId but now i don't know how to get the players name from his UserId can somebody help me?
Here's the code:
local playeringame = {}
local Status = game.ReplicatedStorage:WaitForChild("Status")
Status.Value = "Waiting For Players..."
game.Players.PlayerAdded:Connect(function(player)
repeat
wait()
until #game:GetService("Players"):GetPlayers() >= 1
wait(2)
for i = 4, 1, -1 do
Status.Value = "Staring Game in "..i
wait(1)
end
Status.Value = "Loading Map..."
local ClonedMap = game.ReplicatedStorage.Maps.Map01:Clone()
ClonedMap.Parent = workspace
ClonedMap.Name = "Map"
wait(2)
game.ReplicatedStorage.NumbersPlayersInGame.Value = #game:GetService("Players"):GetPlayers()
table.insert(playeringame, player.UserId)
player.Character.HumanoidRootPart.CFrame = workspace:WaitForChild("Map").Spawns.Spawn.CFrame
player.Character.Humanoid.Died:Connect(function()
game.ReplicatedStorage.NumbersPlayersInGame.Value -= 1
table.remove(playeringame, player.UserId)
end)
repeat
wait()
until game.ReplicatedStorage.NumbersPlayersInGame.Value == 1
if game.ReplicatedStorage.NumbersPlayersInGame.Value == 1 then
Status.Value = "Game Ended"
game.ReplicatedStorage.NumbersPlayersInGame.Value = 0
game.ReplicatedStorage.LastPlayer.Value = playeringame[1]
print(playeringame[1])
end
end)

1 comment
Thanks Man!