Hey, anyone who is reading this
I've been making a script but only the playeradded seems to work and not remove, if anyone could help that would be nice.
--Get the workspaces player folder so we can later on set values to clone player--
local player_folders = game.Workspace:WaitForChild("Players")
-- --
--Get each individual player object value--
local player1 = player_folders:WaitForChild("Player1")
local player2 = player_folders:WaitForChild("Player2")
local player3 = player_folders:WaitForChild("Player3")
-- --
--Set the value to an entered player, if a value is free--
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
wait(0.5)
if player1.Value == nil then
player1.Value = char
elseif player2.Value == nil then
player2.Value = char
elseif player3.Value == nil then
player3.Value = char
end
end)
end)
-- --
game.Players.PlayerRemoving:connect(function(plr)
wait(0.5)
if player1.Value == plr.Character then
player1.Value = nil
elseif player2.Value == plr.Character then
player2.Value = nil
elseif player3.Value == plr.Character then
player3.Value = nil
end
end)
Thanks to anyone who can help!

1 comment
Does the wait(.5) in the PlayerRemoving event affect anything if removed? My guess is that the event is referencing a player that has already disconnected.