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

How to make a click detector spam filter?

Hi. can someone help me with a spam filter? can someone do so if they spam click, it only redeems 1 click per second?

script: script.Parent.MouseClick:Connect(function(player) if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Cash") then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 25 end end)

3 answers

✓ Accepted answer

I am assuming that you meant "Cooldown", Well then, you should use a boolvariable with an if statement!

local bool = true

    script.Parent.MouseClick:Connect(function(player)  
    if bool == true and player:FindFirstChild(“leaderstats”) and player.leaderstats:FindFirstChild(“Cash”) then 
    bool = false
    player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 25 
    wait(1) -- cooldown
    bool = true
    end  
    end) 

After the MouseClick event, it will do what u want it to do and wait for 1 second for it to work again.

8 comments

0

This does not work

0

Maybe your script is not on LocalScript, or try putting the bool = true which is in line #8 after the line #9...

0

Hmmm still not working

0

Workspace.Region.Main Biome.Trees.Woodland Biome Type 1.Union.ClickDetector.Scr:4: unexpected symbol near '?'

0

can u take a screenshot?? of ur script...

0

Its a local script btw

0

ur line 4's string sign is wrong, use "" and not that, it should be: :FindFirstChild("leaderstats") and the cash one too, but im guessing that u have already fixed it since u accepted my answer..

script.Parent.MouseClick:Connect(function(player) 
 if player:FindFirstChild(“leaderstats”) and player.leaderstats:FindFirstChild(“Cash”) then 
     player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 25
     wait(1) -- Change this to whatever number you would like 
     end 
  end) --If this doesn't work please tell me

1 comment

0

That does not work

how about:

debounce = false
        script.Parent.MouseClick:Connect(function(player)  
        if not debounce then
        debounce = true
    if player:FindFirstChild(“leaderstats”) and player.leaderstats:FindFirstChild(“Cash”) then  
    player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 25 
    wait(1)
    debounce = false
    end 
    end  
    end)

2 comments

0

sorry about the way its presented

0

Doesn't work

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