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

Why does this character loading script only work for the first player in the server?

Asked by 6 years ago

Hey! I'm working on a custom character morphing system and although the following script works perfectly for the first player to enter a server, every other player that follows cannot load their character. I wonder if it's a deceptively simple problem and could really use some advice.

game.Players.CharacterAutoLoads = false

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        local humanoid = character:FindFirstChild("Humanoid")
        if humanoid then
            humanoid.Died:connect(function()
                wait(4)
                player:LoadCharacter()
            end)
        end
    end)
    game.Lighting.StarterCharacter3.Parent = game.StarterPlayer
    game.StarterPlayer.StarterCharacter3.Name = 'StarterCharacter'
    player:LoadCharacter()
end)
0
on line 13, you re-parent instead of :Clone() the instance. RubenKan 3615 — 6y

2 answers

Log in to vote
1
Answered by
GingeyLol 338 Moderation Voter
6 years ago
Edited 6 years ago

the character model is only moved into the StarterPlayer service after they join, and its nil when they join for the first time because it loads into the service after

0
Oh thankyou Samstergizmo 28 — 6y
Ad
Log in to vote
0
Answered by 6 years ago

You shouldn't use Lighting as a method of storage anymore and I'm guessing the script breaks altogether because you're setting the parent of StarterCharacter3 to something else, meaning that the second time someone joins, it won't be indexed and your code will break at like 13 and it won't execute the code at line 15, which loads the player's character.

Answer this question