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

I want a players color of their robloxian skin to change. I have a script, but what did I do wrong?

Asked by 10 years ago
player=game.Players.LocalPlayer


script.Parent.MouseButton1Down:connect(function()

if player.Character:findFirstChild("Head") then
player.Character.Head.BrickColor = "Pastel brown"
else
local h = Instance.new("Head", player.Character)
h.Head.BrickColor ="Pastel brown"
end

end)

This is what I put into a local script in a gui.

1 answer

Log in to vote
2
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
10 years ago

The problem with your code is on line 9 where you attempted to create an Invalid Instance 'Head'. Head isn't a valid instance type

But alternatively, instead of coloring each limb individually why don't you use a loop to iterate through all the children of the player's character.. then changing any parts(potential limbs)'s colors to the specified color?

local plr = game.Players.LocalPlayer
local color = BrickColor.new('Pastel brown')

script.Parent.MouseButton1Down:connect(function()
    if plr.Character then
        for i,v in pairs(plr.Character:GetChildren()) do
            if v:IsA('BasePart') then v.BrickColor = color end
        end
    end
end)
0
Thanks. I found a mistake you made in line 7 you did not define plr so I used player. Relampago1204 73 — 10y
Ad

Answer this question