Basically I'm assigning a player to a conveyor when they join the game. I currently have 2 conveyors setup but when I test it, the player is getting assigned to both. I'm not sure how to stop the function once it's found and assigned the player.
local foundCov = false
game.Players.PlayerAdded:connect(function(plr)
for i,v in pairs(workspace.Config.ownerNames:GetChildren()) do
numOfCov = i
end
for i = 1,numOfCov do
if workspace.Config.ownerNames["owner"..i].Value == "" and foundCov == false then
foundCov = true
workspace.Config.ownerNames["owner"..i].Value = plr.Name
return
end
end
end)

1 comment
Try using a "break" where you want the loop to stop after assigning a player.