GIF preview are not public due to private issues.
local part = script.Parent local ceiling = workspace.ce debounce = false function ontouched() debounce = true ceiling.Transparency = 1 debounce = false end function touchedended() debounce = true ceiling.Transparency = 0 debounce = false end script.Parent.Touched:Connect(function(ontouched) print("Touching") end) script.Parent.TouchEnded:Connect(function(touchedended) print("Touch Ended") end)
Does anything blocks the debounce to work?
There no error at all, every help is appreciated.
So the problem is that you're printing ("Touching") or ("Touch Ended") for each touch, not connecting to the actual function. You're also not waiting between them and instantly setting the debounce to true/false.
To fix it:
1) Delete the lines that say print()
and end)
.
2) Have a wait between setting debounce and have a check for the debounce.
Fixed script:
local part = script.Parent local ceiling = workspace.ce debounce = false local waitTime1 = 3; -- Time to wait on the onTouched before resetting debounce. local waitTime2 = 3; -- Time to wait on the TouchEnded function before resetting debounce. function ontouched() if debounce then return end; -- If debounce is true, then stop here, else, continue. debounce = true ceiling.Transparency = 1 wait(waitTime1); debounce = false end function touchedended() if debounce then return end; -- If debounce is true, then stop here. Else, continue. debounce = true ceiling.Transparency = 0 wait(waitTime2); debounce = false end script.Parent.Touched:Connect(function(ontouched); script.Parent.TouchEnded:Connect(function(touchedended);
Please accept as answer if this worked for you.