Trying to make an amount of clicks leaderboard

So, I’m making a game where you have a tool that you can use, and I want to make a leaderboard to keep track of the number of clicks the user has made with the tool out, I’ve tried scouring the internet for help but so far my search has been in vain.

Any idea how I could do this? Thanks in advance.

Edit: The actual leaderboard is fine, I just need a way to add on points to the leaderboard

2 Likes

You can create a Leaderstats and add a value inside of it named “TotalClicks” or something similiar. Then you can listen to the Tool.Activated Event on the Server and then increment the number of TotalClicks by 1.

It’s recommended that you add a Debounce (AKA Cooldown) to don’t let the Player spam their tool, Since if they do, This would “break” the TotalClicks value and make it absurdly high if they’re using an Auto Clicker.

1 Like

I can see what you mean, but it doesn’t seem to be working for me

(My script might just suck haha)

(Code below)

local Players = game:GetService("Players")
local Clicked = game.StarterPack.Battery
local TotalClicks = Instance.new("IntValue")

local function onPlayerAdded(player)
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player

	TotalClicks.Name = "Clicks"
	TotalClicks.Value = 0
	TotalClicks.Parent = leaderstats
end

local function AddPoint()
	TotalClicks.Value = TotalClicks.Value + 1
	wait(0.5)
end

Players.PlayerAdded:Connect(onPlayerAdded)
Clicked.Activated:Connect(AddPoint)