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

Adding body colors/cloning from lighting?

Removing all hats and clothes from a player before adding custom body colours. It removes hats and clothes but fails to add body colours. I may be going about this the wrong way but this is the simplest I can see.

game.Players.PlayerAdded:connect(function(plr) 
    plr.CanLoadCharacterAppearance = false
	lbbc = game.Lighting["Body Colors"]
	local bbc = lbbc:clone()
	bbc.parent = game.Workspace.plr
end)

2 answers

You error is line 5. parent should be capitalized, but the main problem is game.Workspace.plr. plr is a parameter of the PlayerAdded event which is equal to the player that joined the game. It is not a string equal to the player's name, it is equal to the player itself. But even if it was equal to the player's name, it still wouldn't work! That is because, when you use the dot (.) to look for a child of an object, it does not take strings. You could do game.Workspace[plr.Name]with brackets, but since a player has a Character property, why not just use that?

game.Players.PlayerAdded:connect(function(plr) 
	plr.CanLoadCharacterAppearance = false
	lbbc = game.Lighting["Body Colors"]
	local bbc = lbbc:Clone()
	bbc.Parent = plr.Character
end)

3 comments

0

CanLoadCharacterAppereance prevents the body colors from loading in and thus the player does not have body colors to change

0

Oh, my bad. Just go with the first things I said then.

0

I also just thought of something that would be a better way to do it... Read it again.

Cheers Perci1 for the help. I tried your suggestion and I didn't work but it did not though a error. So I investigated into the .Character more and added a extra line of code to make it work!

game.Players.PlayerAdded:connect(function(plr)  
    plr.CanLoadCharacterAppearance = false 
    lbbc = game.Lighting.BodyColors
    local bbc = lbbc:Clone()
	plr.CharacterAdded:wait()  -- Added this bit!
    bbc.Parent = plr.Character
end) 

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