So i’m making a local script in a gui biutton. Its supposed to change the color of a player’s clothes. Though it doesnt work and i’m getting the error message: Players.trueblockhead101.PlayerGui.Customize.Frame.Red.LocalScript:8: attempt to index nil with ‘Color’
Here is the script:
local player = game.Players.LocalPlayer
function Color()
local C = player.Character:FindFirstChild{"hat2", "Shirt", "hat1", "sleeve1", "sleeve2","pant1","pant2"}
C.Color = Color3.new(1, 0, 0)
end
script.Parent.MouseButton1Click:Connect(Color)
1 Like
I’m pretty sure FindFirstChild doesn’t accept arrays as an input value. Instead, make a separate array and loop through it to color it.
local function Color()
local items = {"hat2", "Shirt", "hat1", "sleeve1", "sleeve2","pant1","pant2"}
for _, item in ipairs(items) do
local C = player.Character:FindFirstChild(item)
C.Color = Color3.new(1, 0, 0)
end
end
2 Likes
Ok so this script kinda works. The hat, the sleeves change color. Though the pants and the shirt dont.
Any ideas?
Make sure the items on your list are spelled/formatted exactly as the items your character is wearing. Another reason why this could be happening is there might be a decal on the shirts or pants.
would it make a difference if they were unions?
And they are spelled correctly with no decals. But they are unions
Oh wait it would because for some reason unions cant change color
They won’t change color becuase you need UsePartColor set to true
1 Like
Ok I changed up the unions so now everything is colored. Thanks