You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I want to have a GUI that pops up when you drive your A-Chassis based car through a certain block, in that gui you can use a slider to select a RGB Gradient color and a slider for the saturation of the color, then when pressing a button, it changes your car’s color to the chosen color.
What is the issue? My output shows no errors when preparing the script, or when pressing the button, yet the meshes of the car that are supposed to change colour, do not change. The meshes do not have any textures.
What solutions have you tried so far? I’ve tried to change the way the found meshes change their color depending on the sliders preview colour (but I’m stuck with having a Color3 and a BackgroundColor3) as well as the textboxes for adding the numbers yourself.
wait(.2)
function Click(mouse)
local plr = script.Parent.Parent.Parent.Parent.Parent
local plrname = plr.Name
local carname = plrname.."'s Car"
for i, carcheck in pairs(game.Workspace:GetChildren()) do
if carcheck.Name == carname then
local car = carcheck
local R = script.Parent.Parent.RGBInput.R.TextBox.Text
local B = script.Parent.Parent.RGBInput.B.TextBox.Text
local G = script.Parent.Parent.RGBInput.G.TextBox.Text
for i, v in pairs(car.Body:GetChildren()) do
if v.Name == "Colors" then
for i, part in pairs(v:GetChildren()) do
if part.Name == "Color" then
part.Color = Color3.new(R,G,B)
end
end
end
end
end
end
end
script.Parent.MouseButton1Down:connect(Click)
I’m really not the best at scripting, most of the code is taken from different sources and examples.
It does work if I have the colour be a pre defined colour, but I don’t want to have a whole gui full of different coloured buttons, if it can be avoided.
I haven’t gotten any errors that I can find. Other parts of the script work, the preview shows the gradient of color you choose by sliding the slider of the RGB Gradient, as well as the saturation.
On the client in that local script, you should do the following:
function Click(mouse)
local plr = script.Parent.Parent.Parent.Parent.Parent
local plrname = plr.Name
local carname = plrname.."'s Car"
local RemoteEvent = game.ReplicatedStorage.RemoteEvent -- create a remote event but name it something else and replace the .RemoteEvent with the new name
for i, carcheck in pairs(game.Workspace:GetChildren()) do
if carcheck.Name == carname then
local car = carcheck
local R = script.Parent.Parent.RGBInput.R.TextBox.Text
local B = script.Parent.Parent.RGBInput.B.TextBox.Text
local G = script.Parent.Parent.RGBInput.G.TextBox.Text
RemoteEvent:FireServer(R,G,B) -- send the parameters to the server
end
end
end
end
end
On the server:
local RemoteEvent = game.ReplicatedStorage.RemoteEvent
RemoteEvent.OnServerEvent:Connect(function(player, R, G, B)
for i, carcheck in pairs(game.Workspace:GetChildren()) do
if carcheck.Name == carname then
local car = carcheck
for i, v in pairs(car.Body:GetChildren()) do
if v.Name == "Colors" then
for i, part in pairs(v:GetChildren()) do
if part.Name == "Color" then
part.Color = Color3.FromRGB(R,G,B)
end
end
end
end
end
end)