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

Load StarterCharacter, Keep Body Colors from original, any help?

Asked by 5 years ago

So my main goal is to load in a custom character rig in StarterPlayer and to keep the Body Colors value from the original players character meaning the old body colors will go into the starter character. I want this to replicate with the server so this is what I have done so far.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    local appearanceModel = game.Players:GetCharacterAppearanceAsync(player.UserId)
    appearanceModel["Body Colors"]:Clone().Parent = player.Character
end)

Note: the custom player is in game.StarterPlayer and its named "StarterCharacter"

0
why not edit the player with a playerAdded event? ReallyUnikatni 68 — 5y
0
having a startercharacter makes it seem more simpiler and editing the character entirely from a script was deprecated I think MicroStud -6 — 5y

2 answers

Log in to vote
0
Answered by
xPolarium 1388 Moderation Voter
5 years ago
Edited 5 years ago

Use :LoadCharacter(), which is a function of the Player object which you also get from the PlayerAdded event. This loads the character with the 'StarterCharacter' model you give them in StarterPlayer.

This would go before you parent the Body Colors to the Character since you need the Character to exist first.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    player:LoadCharacter()

    local originalCharacter = Players:GetCharacterAppearanceAsync(player.UserId)
    local originalColors = originalCharacter:FindFirstChild("Body Colors")

    local newColors = original:Clone()
    charColors.Parent = player.Character
end)

Note that you also have CharacterAppearanceLoaded to help you further extend makes custom characters using their current loaded appearance.

Like the code above that loads a model, there's also GetCharacterAppearanceInfoAsync that gives you their appearance info in dictionary format.

Let me know if you need something explained or if I missed anything.

References:

0
Thanks dude, that helped me out a bit too. MicroStud -6 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Found the issue! I had the script disabled and inside of startercharacter scripts rendering it useless and I updated the code a bit. For anybody referencing off of this for their own games here is the script:

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    local appearanceModel = game.Players:GetCharacterAppearanceAsync(player.UserId)
    local bodyColors = appearanceModel:FindFirstChildOfClass("BodyColors"):Clone()
    bodyColors.Parent = workspace[player.Name]
end)

The script is also inside of ServerScriptService and HTTPrequests is on.

Answer this question