Works normally, but I want the script to have a debounce. Whenever i try to add a debounce though, it just doesn't run.
script.Parent.Touched:Connect(function(throw) local debounce = false if debounce then debounce = true script.Parent.Anchored = false script.Parent.Velocity = script.Parent.Velocity + Vector3.new(-100, 100, -100) wait(0.25) script.Parent.Parent.Parent.leaves.oddleaves.WeldConstraint.Enabled = false local explosion = Instance.new("Explosion", workspace) explosion.Position = script.Parent.Parent.Parent.leaves.oddleaves.Position wait(0.45) debounce = false end end)
Whenever I try to touch the part which should start this script, nothing happens. Wiki hasn't exactly been helping very much, either.
Make sure on line three you check that it's false, not true.
script.Parent.Touched:Connect(function(throw) local debounce = false if debounce then -- "If true then"
SO you would want it like this:
script.Parent.Touched:Connect(function(throw) local debounce = false if not debounce then -- if not true (aka false)
Because the decision structure will only carry through if the condition is true, even though you set it false before hand.