I am trying to make a car painting system using SurfaceGUI's. However, In my code, it changes the color of every other car that previously used the coloring system. I only want it to color the car that is sitting on the brick.
Heres the code:
local detectorpad = script.Parent.Parent.Parent.Parent.Parent.Pad
local carPresent = script.Parent.Parent.carPresent
detectorpad.Touched:Connect(function(part)
script.Parent.MouseButton1Click:Connect(function()
if part.Name == "Wheel" then
local car = part.Parent
local descendants = car.BodyPanels:GetDescendants()
for index, descendant in pairs(descendants) do
if descendant:IsA("Part") then
descendant.BrickColor = BrickColor.new("Cyan")
print "wee"
end
if descendant:IsA("WedgePart") then
descendant.BrickColor = BrickColor.new("Cyan")
local car = nil
end
end
script.Parent.Parent.Parent.Parent.button:Play()
script.Parent.Parent.Visible=false
wait(10)
script.Parent.Parent.Parent.TextButton.Visible=true
end
end)
end)
