Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do you make scripts activate when players join and when players are ready to play the game?

there are scripts that run while a player is trying to join a new server and that sometimes prevents players from actually join the game so then the game is impossible to play. i need someone to make a code to add into a script where the script activates when players actually join the game and are ready to play the game .

2 answers

Theres two ways to do this :

game:GetService("Players").PlayerAdded:connect(function(player)
	workspace:WaitForChild(player.Name)
	-- Code after character spawned here
end)

Note : The code will run only once and that is when the player first joins the game

or

game:GetService("Players").PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function(character)
		-- Code after character spawned here
	end)
end)

Note : The code will run every time a player respawns and not just the first time joining

This discussion is preserved as it was. New answers, comments, and votes are closed.