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

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

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"

2 comments

0

why not edit the player with a playerAdded event?

0

having a startercharacter makes it seem more simpiler and editing the character entirely from a script was deprecated I think

2 answers

✓ Accepted answer

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:

1 comment

0

Thanks dude, that helped me out a bit too.

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.

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