I finally finished the leaderstats. Is it working cleanly?

https://www.roblox.com/games/6922866766/Aim-Trainer

The script took a while. If you have any questions or need to see/check the script just reply and I’ll send it! Thanks. Btw, feed back appreciated.

Thanks for @Jackscarlett for helping me understand basic concepts! :smiley:

I tried 3 times, but it only worked once. The other two times it just didn’t keep track. Can you send the leaderstats script?

local function onPlayerJoin(player)

local leaderstats = Instance.new(“Folder”)

leaderstats.Name = ‘leaderstats’

leaderstats.Parent = player

local clicks = Instance.new(‘IntValue’)

clicks.Name = ‘TargetsHit’

clicks.Value = 0

clicks.Parent = leaderstats

end

game.Players.PlayerAdded:Connect(onPlayerJoin)

Script 2:

local part = script.Parent

local TargetsHit = part.ClickDetector

local clickAmount = 0

local canClick = true

local function addClick(player)

if canClick then

  player.leaderstats.TargetsHit.Value = player.leaderstats.TargetsHit.Value + 1

  clickAmount = clickAmount + 1

end

if clickAmount >= 10000000000 then

  clickAmount = 0

  canClick = false

  part.BrickColor = BrickColor.new('Really red')

  wait(3)

  part.BrickColor = BrickColor.new('Medium stone grey')

  canClick = true

end

end

TargetsHit.MouseClick:Connect(addClick)