This is an emergency, I added a global leaderboard to my roblox game but people are downloading autoclicker, I need to find a way to delay the tool from being spammed, here's the script.
01 | local sound = workspace.Sound |
02 | local tool = script.Parent |
03 |
04 |
05 | tool.Activated:Connect( function () |
06 | local character = tool.Parent |
07 | local players = game:GetService( "Players" ) |
08 | local player = players:GetPlayerFromCharacter(character) |
09 | local leaderstats = player.leaderstats |
10 | local currency = leaderstats.GamerScore |
11 | local addition = 500 |
12 |
13 | sound.Playing = true |
14 | currency.Value = currency.Value + addition |
15 |
16 |
17 | end ) |
To prevent it from being spammed, you need to make a variable to see it has been used recently
01 | local sound = workspace.Sound |
02 | local tool = script.Parent |
03 | local enabled = true |
04 |
05 | tool.Activated:Connect( function () |
06 | if not enabled then return end |
07 | enabled = false |
08 | local character = tool.Parent |
09 | local players = game:GetService( "Players" ) |
10 | local player = players:GetPlayerFromCharacter(character) |
11 | local leaderstats = player.leaderstats |
12 | local currency = leaderstats.GamerScore |
13 | local addition = 500 |
14 |
15 | sound.Playing = true |
just add a wait or delay.
01 | local sound = workspace.Sound |
02 | local tool = script.Parent |
03 |
04 |
05 | tool.Activated:Connect( function () |
06 | local character = tool.Parent |
07 | local players = game:GetService( "Players" ) |
08 | local player = players:GetPlayerFromCharacter(character) |
09 | local leaderstats = player.leaderstats |
10 | local currency = leaderstats.GamerScore |
11 | local addition = 500 |
12 |
13 | sound.Playing = true |
14 | currency.Value = currency.Value + addition |
15 |
16 | wait( 5 ) -- (or you could add delay(5), depending what you choose) |
17 |
18 | end ) |