Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 10 years ago

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

Log in to vote
0
Answered by
samfun123 235 Moderation Voter
10 years ago

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

Ad
Log in to vote
-2
Answered by 10 years ago

use a Playeradded function

Answer this question