Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my debounce not working?

Asked by 8 years ago

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

Log in to vote
1
Answered by 8 years ago

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

0
Thanks for the help bro! Want something I can do in return? fahmisack123 385 — 8y
0
no thanks dude but thanks for the offer ProfessorSev 220 — 8y
Ad

Answer this question