I have this script which reads if a value is changed to 1, and if it is then it kills you and plays a noise. However when the value is changed to 1, and then back to 0, this script stays active and keeps killing and playing noises when the parent block is touched. Is there any event or function I can do so that it disables when changed back to 0?
local yo = script.Parent.Parent.yo local debounce = false yo.Changed:Connect(function(newval) --event im using to trigger this, doesnt work as intended, any better alternatives for my situation? if newval==1 then -- this too script.Parent.Touched:Connect(function(hit) if debounce==false then local h = hit.Parent.Humanoid if h.health>0 then debounce=true h.Health = 0 script.Parent.Parent.SoundPlayer.honk:Play() wait(1) debounce=false end end end) elseif newval==0 then --attempt to make the script not work when value is 0 print('safe') end end)