so im trying to make it when the player leaves lets play if player1 leaves whoever is in player2 get coverted to player1 and player3 gets converted to player2 and so on
local players = game:GetService("Players")
local function onPlayerAdded(player)
local playerCount = #game.Players:GetPlayers()
local playerinstance = workspace:FindFirstChild("Player"..playerCount)
print(playerinstance)
local position = playerinstance
print(position)
position.Value = player.Name
position.Parent = workspace
end
local function onPlayerRemoving(player)
local playerCount = #game.Players:GetPlayers()
local playerinstance = workspace:FindFirstChild("Player"..playerCount)
local position = playerinstance
for _, _player in ipairs(players:GetPlayers()) do
local _position = _player.Position
if _position.Value > position.Value then
playerinstance = workspace:FindFirstChild("Player".._position.Value)
_position.Value -= 1
end
end
end
players.PlayerAdded:Connect(onPlayerAdded)
players.PlayerRemoving:Connect(onPlayerRemoving)