Color accessory gui not working

I made a script where if a user changes the color of an imagelabel using a colorwheel gui and clicks a textbutton, it changes an accessory’s meshpart color to the imagecolor of an imagelabel.

the problem is that i cant get it to change the color based on the imagecolor. I cant further explain since english isnt my first language but heres the script:

local confirmbutton = script.Parent.Confirm 
local colorclothes = game.ReplicatedStorage:WaitForChild("ColorClothes")

local finalcolor = script.Parent.Parent.Parent.ColourWheelGui.Frame.ColourDisplay

local character = game.Players.LocalPlayer.EquippedAccessories() 
for i, v in pairs(character:GetChildren()) do if v:IsA("Accessory") then
	end
	
local Accessory = character
	for i, v in pairs(character:GetChildren()) do if v:IsA("MeshPart") then
		end
		
		colorclothes.OnServerEvent:Connect(function()
			confirmbutton.MouseButton1Click:Connect(function()
				Accessory.Color = finalcolor.BackgroundColor3

if you can help it would really mean alot
(excuse if i made a few grammar mistakes as english isnt my first language)

1 Like

Your indentation confuses me a little, but anyway if you’re trying to get all the equipped accessories on a character, then you can use Players.LocalPlayer.Character.Humanoid:GetAccessories()

may i ask on where to put this line?

I’d put it in the connection to your button, like this:

confirmButton.MouseButton1Click:Connect(function()
    for _,accessory in game.Players.LocalPlayer.Character.Humanoid:GetAccessories() do
        accessory.Handle.Color = finalcolor.BackgroundColor3
    end
end)

Make sure it’s replacing the loop which you originally used to get the accessories.

1 Like


it still shows this error

Can you show me the whole script? It’s probably just a missing end for another loop.


here

Your code structure is certainly… odd…
Anyway, you seem to only have copied half the code I sent you. Try copying and pasting the whole thing this time.

I have corrected your script:

local confirmbutton = script.Parent.Confirm 
local colorclothes = game.ReplicatedStorage:WaitForChild("ColorClothes")

local finalcolor = script.Parent.Parent.Parent.ColourWheelGui.Frame.ColourDisplay

local character = game.Players.LocalPlayer.EquippedAccessories() 
for i, v in pairs(character:GetChildren()) do 
	if v:IsA("Accessory") then


		local Accessory = character
		
		for i, v in pairs(character:GetChildren()) do 
			if v:IsA("MeshPart") then


				colorclothes.OnServerEvent:Connect(function()
					confirmbutton.MouseButton1Click:Connect(function()
						Accessory.Handle.TextureId = ""
						Accessory.Handle.Color = finalcolor.BackgroundColor3
					end)
				end)
				
			end
		end
	end	
end

Please reply how it does :slight_smile:

it sadly didnt change the color

Change the whole script to be:

local confirmbutton = script.Parent.Confirm
local finalcolor = script.Parent.Parent.Parent.ColourWheelGui.Frame.ColourDisplay

confirmButton.MouseButton1Click:Connect(function()
    for _,accessory in game.Players.LocalPlayer.Character.Humanoid:GetAccessories() do
        accessory.Handle.Color = finalcolor.BackgroundColor3
    end
end)

I don’t know what the colorclothes RemoteEvent was for so I’ve left it out.

thank you, this one actually worked. the problem was the remoteevent i think

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.