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.
local sound = workspace.Sound local tool = script.Parent tool.Activated:Connect(function() local character = tool.Parent local players = game:GetService("Players") local player = players:GetPlayerFromCharacter(character) local leaderstats = player.leaderstats local currency = leaderstats.GamerScore local addition = 500 sound.Playing = true currency.Value = currency.Value + addition end)
To prevent it from being spammed, you need to make a variable to see it has been used recently
local sound = workspace.Sound local tool = script.Parent local enabled = true tool.Activated:Connect(function() if not enabled then return end enabled = false local character = tool.Parent local players = game:GetService("Players") local player = players:GetPlayerFromCharacter(character) local leaderstats = player.leaderstats local currency = leaderstats.GamerScore local addition = 500 sound.Playing = true currency.Value = currency.Value + addition wait(5) enabled = true end)
just add a wait or delay.
local sound = workspace.Sound local tool = script.Parent tool.Activated:Connect(function() local character = tool.Parent local players = game:GetService("Players") local player = players:GetPlayerFromCharacter(character) local leaderstats = player.leaderstats local currency = leaderstats.GamerScore local addition = 500 sound.Playing = true currency.Value = currency.Value + addition wait(5) -- (or you could add delay(5), depending what you choose) end)