Player leaving breaks script?

how do I make it so my scripts wont break when a player leaves the game when it’s activated?

game.Players.PlayerRemoving:Connect(function(player)
	
end)

How is the script(s) in question breaking your game when the player leaves? The game completely stops working or what is happening?
A bit confused by the question, could just be me not having english as my native language (I would expect more detailed information about your problem)

like if I were to have a script that prints a players name 3 times when they touch a part, and between each print was wait(3).

How would i stop the console from sending an error if the player were to leave when the server is trying to print their name?

Still not getting why’d you do that, however you could set a variable equal to the player’s name and then print the variable. That would be the easiest, however if you want it to stop printing if the player left the game, then you could do something like *if player and player.Parent then … end

Edit: You’d had to check before each print.
Ex:
–check
print(player.Name)
task.wait(3)
–check
print(player.Name)
task.wait(3)
–check
print(player.Name)

You said that you waited each time, assumed you did it something like that. Personally I’d use a for loop.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.