There’s no debounce so your part’s pseudo-infinitely turning back to its first colour. Your code, otherwise, works fine - it’s just an oversight that you haven’t accounted for.
local debounce = false
Touched:Connect(function ()
if not debounce then return end
debounce = true
-- Colour your parts
debounce = false
end)
Are you checking to make sure the part isn’t already being touched?
local IsBeingTouched = false
script.Parent.Touched:Connect(function()
if not IsBeingTouched then
IsBeingTouched = true
print("Touched.")
script.Parent.BrickColor = BrickColor.new("Institutional white")
task.wait(2)
script.Parent.BrickColor = BrickColor.new("Medium stone grey")
IsBeingTouched = false
end
end)
The problem with that script at the moment is that “BrickColor” takes a BrickColor object, and Color actually uses Color3. You should change the script.Parent.BrickColor to just script.Parent.Color.
And another thing - the .Touched() event fires when anything touches the part, that includes other parts, not just players!
Utilizing .Touched is a perfectly acceptable way of handling checkpoints. But you need to check what is exactly touching the part.
I recommend looking through the Touched Event documentation on the Wiki, and checking out maybe some YouTube tutorials on the event if that fits you better.
I used the code below, and this works perfectly, thank you all for the help! The problem was that 1, Color is easier to use, and I for color you have to you HSV, which is a 0-1 scale
local IsBeingTouched = false
script.Parent.Touched:Connect(function()
if not IsBeingTouched then
IsBeingTouched = true
print("Touched.")
script.Parent.Color = Color3.fromHSV(0.457833, 1, 0.666667)
task.wait(2)
script.Parent.Color = Color3.fromHSV(0.722222, 0.0181888, 0.647059)
IsBeingTouched = false
end
end)