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

How to make a click detector spam filter?

Asked by 5 years ago

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

Log in to vote
0
Answered by 5 years ago

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.

0
This does not work johnoscarbhv1 137 — 5y
0
Maybe your script is not on LocalScript, or try putting the bool = true which is in line #8 after the line #9... NickAtNick 163 — 5y
0
Hmmm still not working johnoscarbhv1 137 — 5y
0
Workspace.Region.Main Biome.Trees.Woodland Biome Type 1.Union.ClickDetector.Scr:4: unexpected symbol near '?' johnoscarbhv1 137 — 5y
View all comments (4 more)
0
can u take a screenshot?? of ur script... NickAtNick 163 — 5y
0
Its a local script btw johnoscarbhv1 137 — 5y
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.. NickAtNick 163 — 5y
Ad
Log in to vote
0
Answered by 5 years ago
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
0
That does not work johnoscarbhv1 137 — 5y
Log in to vote
0
Answered by 5 years ago

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)
0
sorry about the way its presented Bylli_Oruze 38 — 5y
0
Doesn't work johnoscarbhv1 137 — 5y

Answer this question