I'm trying to make a part change color when you're on it and change back when you get off the part.
This is the problem I'm having. It's flashing when I step on and off really fast.
My current code is:
local pad = script.Parent
local off = BrickColor.new('Medium stone grey')
local on = BrickColor.new('Light blue')
local onPad = false
pad.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if not onPad then
pad.BrickColor = on
onPad = true
wait(1)
end
end
end)
pad.TouchEnded:Connect(function(hit)
if onPad then
pad.BrickColor = off
onPad = false
wait(1)
end
end)

1 comment
Roblox's touch and touch ended is really crappy in terms of functionality. I'll write an answer on an alternative method in a second