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

How to change color of a custom character on a respawn?

Asked by 5 years ago
Edited 5 years ago

as always, the question sounds confusing but what i'm saying is that, how do I change the color of the part in the custom character (lets say like Torso for example when ever a player respawns it changes color). I'm trying to change up the hat color I've added on my custom character for player to play as. Each time they respawn, the hat changes colors but my scripting seems a bit off, and it's not working.

```lua local Players = game:GetService("Players")

local function onCharacterAdded(character)

character.ShadowMaskGiver.Color.BrickColor.BrickColor = BrickColor.Random()

end```

0
ignore the "```" part at the end, that isn't part of the script. TheBuliderMC 84 — 5y
0
I found that adding wait(1) does the trick KinqAustinn 293 — 5y
0
that doesn't seem to work, What really bothers me is that nothing is showing in the output. TheBuliderMC 84 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

It seems like you are not firing the function, instead try this:

local plr = game:GetService("Players")
plr.PlayerAdded:wait() --- i think this line is not needed but just in case
plr.LocalPlayer.CharacterAdded:Connect(function(char)
    character.ShadowMaskGiver.Color.BrickColor.BrickColor = BrickColor.Random()
end)

or if you want something longer you can try:

game:GetService("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        character.ShadowMaskGiver.Color.BrickColor.BrickColor = BrickColor.Random()
    end)
end)           

either that or you can simply add this line at the bottom of your script, this line fires your function:

Players.LocalPlayer.CharacterAdded:Connect(OnCharacterAdded)
0
The 'char' is supposed to be 'character' but i forgot to change it also it won't let me edit it properly richboifexekappa 89 — 5y
Ad

Answer this question