Essentially when a Player is added to the game I want that Player to be assigned either P1, P2, P3 or P4 based on which ones are already taken. I have attempted this in several ways even though I could only think of a few. I will include an example of my code (doesn't work but will most likely help you understand my mindset of this)
local P1 = game.ReplicatedStorage:WaitForChild("Values").P1
local P2 = game.ReplicatedStorage:WaitForChild("Values").P2
local P3 = game.ReplicatedStorage:WaitForChild("Values").P3
local P4 = game.ReplicatedStorage:WaitForChild("Values").P4
local Values = game.ReplicatedStorage:WaitForChild("Values")
game.Players.PlayerAdded:Connect(function(player)
local imAssigned = false
if P1.Assigned.Value == false and imAssigned == false then
P1.Value = player.Name
P1.Assigned.Value = true
imAssigned = true
end
if P2.Assigned.Value == false and imAssigned == false then
P2.Value = player.Name
P2.Assigned.Value = true
imAssigned = true
end
if P3.Assigned.Value == false and imAssigned == false then
P3.Value = player.Name
P3.Assigned.Value = true
imAssigned = true
end
if P4.Assigned.Value == false and imAssigned == false then
P4.Value = player.Name
P4.Assigned.Value = true
imAssigned = true
end
end)
Basically there are 4 string values and I want when a new player joins for their name to be set as the value of that string value. But only 1..
So another way of explaining this is: Player Joins > Game Sets ONE of the values that is "none" or nil to that Players name and sets the value.Assigned (Boolean Value) to true.

1 comment
Hi, I tried out the script but it sets ALL the values in Values to the players name, I don't want the players name constantly repeating