I have no idea why this part isn't changing color

I am trying to make a car customization system but I am having trouble getting the colors to change. I tried changing the values to rgb but it still doesn’t work.

Every time you select a color the preview of the car is supposed to change but it doesn’t do anything.

It doesn’t give any errors and none of the values are nil. The color values are stored inside a folder in the vehicle customization gui and the script below finds the parts to color and applys the color values.

Code (Local Script):

local carobjvalue = gui.PreviewCar

for i, v in pairs(bodyColorFrame:GetChildren()) do
	if v:IsA("Frame") then
		local button = v.Button
		local values = v.Values
		
		button.MouseButton1Click:Connect(function()
			hoversound:Play()
			print("clicked")
			if carobjvalue.Value ~= nil then
				print("not nil")
				local carprev = carobjvalue.Value
				print(carprev)
				for i, v in pairs(carprev:GetDescendants()) do
					print("checking")
					if v.Name == "Customize" and v:IsA("StringValue") then
						print("found value")
						if v.Value == "BodyColor" then
							print("found right value")
							print(v.Parent)
							--local r, g, b = values.Color.Value.R*255, values.Color.Value.G*255, values.Color.Value.B*255
							--local RGB_Color = Color3.new(r,g,b)
							--print(RGB_Color)
							v.Parent.Color = values.Color.Value
							print(v.Parent.Color)
							print(values.Color.Value)
							carprev.BodyColor.Value = values.Color.Value -- This is supposed to change the color
						end
					end
				end
			end
		end)
	end
end
3 Likes

Is the part that it is selecting a Union by any chance?

5 Likes

No, it’s a meshpart. And the value doesn’t change in the properties either.

3 Likes

How does the color get applied to the car? Is it instant? And, if so, can I see the code for that?

3 Likes

Is this a local script? If so, you will have to use a remote event to change the color because parts created on the server/in studio cannot be manipulated by the client (aka local scripts)

3 Likes

The model only exists in the client so I don’t think that is an issue. I also have been able to change colors of parts in the workspace in the past.

3 Likes

The only problem I see right now is that you haven’t told the script to change the color of the part.

3 Likes

Does the MeshPart have a texture on it?

3 Likes

Unless that’s what this is and I’m being unsmart

3 Likes

This is wrong. The client can manipulate things, but the changes will only be seen by the client that makes the changes. Since OP is making a preview system, I assume the preview is only seen by the player customizing the colors, meaning using a local script would work.

Just wanted to clarify for anyone else reading.

4 Likes

Yes that is what changes the color

2 Likes

In that case, check to see if DoubleSided is set to true. If it is, set it to false.

2 Likes

Scratch what I said, see if there’s a TextureId applied to the MeshPart.

1 Like

Double sided is off. Also, I am still able to change the color in studio I am just having trouble changing the color in the script.

2 Likes

Okay, that clarifies that. Are there any other scripts that are responsible for changing the color? Or just the one?

2 Likes

This is the only script changing the color.

1 Like

Make sure that the script is targeting the gui that’s in the player’s PlayerGui folder, rather than the one that is within StarterGui. (Assuming that the gui starts in StarterGui)

Sorry I didn’t fully explain it, but yes you are right, I would’ve gone into more depth but this was a topic I thiought would be quick to solve and it wouldn’t really matter

1 Like

The local script is inside the gui so I don’t really need to check the playergui folder

I do want to ask, do all of the print statements you have in your code print?