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
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)
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.
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