I have a problem with spawn() since the code always runs before the player is even added (the script is a script). PlayerAdded does not work because if ex: 1 player joins, the spawn() runs, then another joins then the function is called again, which means that is gets reset.
code foundation:
function example()
--code here
end
spawn(example)
task.spawn does not work either. PlayerAdded is definetly not a good solution since the function will reset once another player joins.
faulty code:
function example()
--code here
end
game.Players.PlayerAdded:Connect(function()
spawn(example)
end)
playing the game in studio works fine but playing it in the roblox player will break it because the code already ran before the player even is added.
Yes. The spawn() runs before the player is even added
example:
Player A joins the game. There is a little delay.
Player A’s player loads into the game. The function already ran, even though its not supposed to run without at least 1 player already in the server. (the script is a script in serverscriptservice)