I would like to make a button that would turn red when clicked when the detector part is being touched and otherwise turn green. I had tried the code below and it turnouts only showing red if a part is starting to touch but not touching. (e.g. if you walk into the part then click the button, it still shows green. If you drive a car slowly into the detector, since parts at the rear of the car is entering the block, it would turn red on click.)
script.Parent.ClickDetector.MouseClick:connect(function()
print("Button")
local Parts = script.Parent.Parent.Detect:GetTouchingParts()
if #Parts == 0 then
script.Parent.BrickColor = BrickColor.new("Lime green")
else
script.Parent.BrickColor = BrickColor.new("Really red")
end
end)
