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

Adding body colors/cloning from lighting?

Asked by 9 years ago

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

Log in to vote
2
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

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)
0
CanLoadCharacterAppereance prevents the body colors from loading in and thus the player does not have body colors to change skunk940 10 — 9y
0
Oh, my bad. Just go with the first things I said then. Perci1 4988 — 9y
0
I also just thought of something that would be a better way to do it... Read it again. Perci1 4988 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

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) 

Answer this question