Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why is my debounce not working?

This script is basically a cash rewarding script for the end of an obby.. I've added a debounce but it doesn't seem to work. I can just keep on touching the brick for 5 seconds and it rewards me every time..

The rest of the code works.

chances = {1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,7,7,7,7,8,8,8,9,9,10}
debounce = false
script.Parent.Touched:connect(function(hit)
	debounce = true
	number = chances[math.random(1,#chances)]
	player = game.Players:FindFirstChild(hit.Parent.Name)
	if player and debounce then
		player.leaderstats.FCash.Value = player.leaderstats.FCash.Value + number
		str = "Well Done "..hit.Parent.Name..". You have earned "..number.." FCash! Did you know? There was a "..11-number.." in 55 chance of getting "..number.."!"
		script.Parent.SurfaceGui.TextBox.Text = str
		wait(5)
		player:LoadCharacter()
	end
	wait(5)
	script.Parent.SurfaceGui.TextBox.Text = "i hop u licked dis11 ;) - g"
	debounce = false
end

1 answer

✓ Accepted answer

You forgot 1 more part of the script you should also check if debounce is false when it starts

if debounce == false then

at the top

2 comments

0

Thanks for the help bro! Want something I can do in return?

0

no thanks dude but thanks for the offer

This discussion is preserved as it was. New answers, comments, and votes are closed.