I don't know why, but the debounce on this script wont work. I'm not very good with debounce, so i don't know what's failing. Even though I have the debounce script, this script will play a million times when touched
--Variables function fade() script.Parent.Parent.Enabled = true for i = 0, 1, 0.05 do script.Parent.TextTransparency = i wait(0.05) end for i = 1, 0, -0.05 do script.Parent.TextTransparency = i print(i) wait(0.05) end script.Parent.Parent.Enabled = false return end local debounce = false --Variables workspace.Earth.Earth.Touched:connect(function() if debounce == false then debounce = true -- script.Parent.Text = "Earth" fade() end end) workspace.Earth.Earth.TouchEnded:connect(function() if debounce == true then debounce = false script.Parent.Parent.Enabled = false wait(1) debounce = false end end)
I don't know what's wrong.
A player touches a part infinite times in a second, that being said, if you have the same part connected to two touched function then the debounce is completely useless, the value will change and the other function will run, instead of using the same part, use two different parts in the same script and it should work perfectly.