Wig Colour Gui Script

I want to make a script that colours wigs (Meshes)

But for some reason the hairs don’t colour at all. I am using vertex colour codes i was given because idk where i can find them at all so i am limited to like 10. but i want to change the wig colour when the button is pressed, but for some reason it won’t work?

I have tried different buttons, different colours etc but it’s not working.

script.Parent.Frame.Frame[“Open/Close”].MouseButton1Down:connect(function()

if script.Parent.Faces.Visible == false then

script.Parent.Faces.Visible = true

script.Parent.Frame.Frame[“Open/Close”].Text = “Close Skin Tones”

script.Parent.Faces.Title.Visible = true

else

script.Parent.Faces.Visible = false

script.Parent.Frame.Frame[“Open/Close”].Text = “Open Skin Tones”

end

end)

local player = script.Parent.Parent.Parent

local f = script.Parent.Faces.Page1:GetChildren()

local bvalue = script.Parent.Faces.BValue

local blackv = script.Parent.Faces.Blackv

for i=1,#f do

local face = f[i]

if face.Name == “face” then

face.MouseButton1Down:connect(function()

player.Character.Hat.Handle.Mesh.VertexColor = Vector3.new(face.Value)

player.Character.Hat.Part.Mesh.VertexColor = Vector3.new(face.Value)

player.Character.Hat.Union.Mesh.VertexColor = Vector3.new(face.Value)

player.Character.Hat.Mesh.VertexColor = Vector3.new(face.Value)

end)

end

end

If i could get pointers or help on how to make this work? All help is appreciated.

1 Like

I am aware the variables are different that’s because i changed them a few minutes ago to try get it to work and idk why i did that lmao. But yea the variables will match but it still doesn’t work when they’ve matched

When you’re assigning VertexColor on the meshes, you’re taking the Value object itself and using it as the X value in a Vector3. I believe you want to instead take the Value property of the Value Instance. For example:

myMesh.VertexColor = face.Value.Value

This code grabs the Value of the “Value” Instance inside the face and applies it to the mesh’s color.

So i read that and i saw that i was getting the value and not the value within the value and i changed it however it says Part is not a valid member when it is?

script.Parent.Frame.Frame[“Open/Close”].MouseButton1Down:connect(function()

if script.Parent.Faces.Visible == false then

script.Parent.Faces.Visible = true

script.Parent.Frame.Frame[“Open/Close”].Text = “Close Hair Colour Changer”

script.Parent.Faces.Title.Visible = true

else

script.Parent.Faces.Visible = false

script.Parent.Frame.Frame[“Open/Close”].Text = “Open Hair Colour Changer”

end

end)

local player = script.Parent.Parent.Parent

local f = script.Parent.Faces.Page1:GetChildren()

local bvalue = script.Parent.Faces.Page1.face.Value.Value

for i=1,#f do

local face = f[i]

if face.Name == “face” then

face.MouseButton1Down:connect(function()

player.Character.Hat.Handle.Mesh.VertexColor = Vector3.new(bvalue)

player.Character.Hat.Part.Mesh.VertexColor = Vector3.new(bvalue)

player.Character.Hat.Union.Mesh.VertexColor = Vector3.new(bvalue)

player.Character.Hat.Mesh.VertexColor = Vector3.new(bvalue)

player.Character.Hat.myMesh.VertexColor = Vector3.new(bvalue)

end)

end

end

1 Like

Huh, that’s weird. How about you go through all SpecialMeshes in the hat and change their VertexColor instead of applying them one by one.
For instance:

for _, item in pairs(hat:GetChildren()) do
	if item:IsA("SpecialMesh") then
		item.VertexColor = Vector3.new(bvalue)
	end
end

I’m assuming you’re using SpecialMeshes but I might be wrong.

1 Like

Idk what the difference are? I am using a wig mesh in a part.

Well it’s better than guessing what the names are in the hat and it’ll stay compatible if new meshes are added or renamed.

1 Like

Also a little confused how i would implement that script?

script.Parent.Frame.Frame[“Open/Close”].MouseButton1Down:connect(function()

if script.Parent.Faces.Visible == false then

script.Parent.Faces.Visible = true

script.Parent.Frame.Frame[“Open/Close”].Text = “Close Hair Colour Changer”

script.Parent.Faces.Title.Visible = true

else

script.Parent.Faces.Visible = false

script.Parent.Frame.Frame[“Open/Close”].Text = “Open Hair Colour Changer”

end

end)

local player = script.Parent.Parent.Parent

local f = script.Parent.Faces.Page1:GetChildren()

local bvalue = script.Parent.Faces.Page1.face.Value.Value

for i=1,#f do

local face = f[i]

if face.Name == “face” then

face.MouseButton1Down:connect(function()

local children = player.Character.Hat:GetChildren()

for i = 1, #children do

local item = children[i]

if item:IsA(“SpecialMesh”) then

item.VertexColor = Vector3.new(bvalue)

end

end

end)

end

end

That’s how i’ve added it, but i get this error

image

The one with the drop down is the hair

image

I’m not seeing any code that looks for a Handle :thinking: How about changing :GetChildren() to :GetDescendants() in the “children” variable. There could be other scripts that are messing with Hat Handles.

1 Like

I had one previously, but i changed it to the one you showed me to find the special meshes, i will try do that and get back to you :slight_smile: Thanks for help btw

1 Like

I tried to add the get decesants and it didn’t work at all, i’ve also tried to add handles aswell and it’s not working. Am i just being dumb and doing it wrong?

I’m pretty sure the error is from another script trying to micromanage hats. How about you try adding a statement after the VertexColor assignment that prints the same property to see if it’s changing?

item.VertexColor = Vector3.new(bvalue)
print(item.VertexColor)
1 Like

Okay, I’ll add that now :slight_smile:

It’s printing 0,0,0 for some reason?? Idk why since it’s linked up

What kind of ValueObject are you using for the “face.Value” Instance? Maybe it’s replacing the color data with nil because it’s not compatible.

1 Like

image

Vector3Value for vertex since none of the others seem to work like vertex

It would be more helpful if you could put your script in the lua font.

1 Like

How do i do that? and make it lua?

Use ``` at the start and end of the code block.

1 Like

How about you remove the Vector3.new call around bvalue so it uses the actual value

1 Like