A-Chassis Paint GUI Help

Hello everyone!

I’ve created a simple paint GUI for a-chassis.

I just don’t know how I would script it to work because when a player spawns a car the model gets named to the players name then car
image

so if Roblox spawned a car it would say RobloxsCar.

Im not the best at scripting but I do know you would need to do something like this >

script.Parent.MouseButton1Click:Connect(function()
	game.Workspace.playercar.Body.Paint.PAINT.BrickColor = BrickColor.new("Black")
end)

(playercar after workspace is just an example I don’t know if that would be right)

but I don’t know how Id make sure it only paints the players car that they spawned and not other player cars

The GUI would probably be placed in plugins inside the car im guessing?
image

Also if I posted in the wrong category please let me know!

Try using Color3 instead of brick color. That usually works better for me

script.Parent.MouseButton1Click:Connect(function()
	game.Workspace.playercar.Body.Paint.PAINT.Color = Color3.fromRGB(...) -- The 3 numbers for black here.
end)

Yea but idk how to actually get it to get the models name because I just put playercar there as an example but it has to get the name of the model when someone spawns it, otherwise it wont work ;/
and I dont have that kinda knowledge

Since UI’s involve client sided input, you’re going to need to use a RemoteEvent if you want other players to see your car color change. Here’s a rough draft on how this might look.

Local Script:

-- I'm just gonna assume you have all the buttons defined up here
-- whenever a button is pressed to change the color, fire a remote event to replicate the change

local RepStorage = game:GetService("ReplicatedStorage")
local ChangeColor = RepStorage:WaitForChild("ChangeColor") -- This is the remote event
-- example:
colorRedButton.MouseButton1Down:Connect(function()
    ChangeColor:FireServer("Red") -- put the brick color here
end)

Then in a regular script, under ServerScriptService you could have some code to handle that like so:

local RepStorage = game:GetService("ReplicatedStorage")
local ChangeColor = RepStorage:WaitForChild("ChangeColor")

ChangeColor.OnServerEvent:Connect(function(player, color)
    -- player is the player who sent the remote over
    -- color is the color we passed, "Red" for example
    
    local playersCar = workspace:FindFirstChild(player.Name.."sCar")
    if playersCar then
        for _, basePart in pairs(playersCar:GetDescendants()) do
            if basePart:IsA("BasePart") then
                basePart.BrickColor = BrickColor.new(color)
            end
        end
    end
end

This is a very simple version of how it might look. You should just put all your buttons into one table in the LocalScript and optimize it so you only use a for loop instead of individual events per button making your script longer. Another idea, you could add a “Confirm” button at the bottom of your UI so as you click to change the color of your car, it’ll only change it on your client (locally), sort of like a preview. So if the player likes the color, they can hit that “Confirm” button and send it to the server to change the color of their car on everyones screen. Hope this helped.

1 Like

Ok I kinda understand.

Im assuming id have to change this
image
To be able to get the parts inside the model of the car to change the colour?

cause this is how the car model is ordered
image
The PAINT is the actual body part that is going to be changed

With the way I coded it, all Parts under that car model will be changed to whatever the color the player chose. To change that, you could do:

local playersCar = workspace:FindFirstChild(player.Name.."sCar")
if playersCar then
    local paintPart = playersCar.Body.Car.Paint.PAINT
    paintPart.BrickColor = BrickColor.new(color)
end
1 Like