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

Why won't this local script get cloned inside a character?

Asked by 10 years ago

Everything works without errors but the localscript won't get cloned inside the character,why?

game.Players.PlayerAdded:connect(function(Player)
    Character = Player.Character
    print(Character.Name)
    for Number,LocalScripts in pairs (script:GetChildren()) do
        LocalScripts:Clone().Parent = Character
        LocalScripts.Disabled = false
        print(Player.Name,"now has",LocalScripts)
    end

end)

1 answer

Log in to vote
1
Answered by
samy22 10
10 years ago

Player:WaitForChild(Character)

When a player is added, the character,isn't loaded yet, so adding that line will make the function wait until the character exists then it will execute everything below it in the function.

Ad

Answer this question