Lets say I have 2 parts. Front, and FrontDamaged. My script makes Front transparent, and FrontDamaged not transparent, whenever Front touches another part. It also plays a sound when it touches something. The thing is, it has no cooldown. And im stuck on where to add the debounce at.
local Front = script.Parent.Front
local FrontDamaged = script.Parent.FrontDamaged
local sound = script.Parent.Crash
local debounce = false
if not sound.IsLoaded then
sound.Loaded:wait()
end
local function onPartTouched(otherPart)
print(Front.Name .. " has touched " .. otherPart.Name)
Front.Transparency = 1
FrontDamaged.Transparency = 0
sound:Play()
end
Front.Touched:Connect(onPartTouched)
TLDR: I need help putting a debounce so the part wont touch stuff multiple times at once.

5 comments
Front.Touched:Connect(onPartTouched) is underlined red, and i have an error in output that says "18:12:48.076 - Workspace.mcslimemansCar.Crash Script:21: Expected 'end' (to close 'function' at line 11), got ; did you forget to close 'then' at line 12?"
Oh yes. Let me add that in.
Ok done. It has been fixed.
Thanks, it works! I also added in a wait(1) and debounce = false so it can be activated again. Thanks again!
Do you by any chance know how to make it not activate when a player touches it?