This is the standard leaderboard code.
game.Players.PlayerAdded:connect(function(plr) local f = Instance.new("Folder", plr) f.Name = "leaderstats" local coins = Instance.new("IntValue", f) coins.Name = "Coins" coins.Value = 0 end)
Click collect: What should I add to the code to work? the I click, I will earn + 1point/coins for example.
function onClicked() if model:FindFirstChild("Humanoid") ~= nil then if model.Humanoid:GetState() == Enum.HumanoidStateType.Dead then --]] put the code collect points end end button.Regen:Play() end button.ClickDetector.MouseClick:Connect(onClicked)
ClickDetector.MouseClick event has Player instance (the Player who click the detector). So the "click collect" script would be like this:
function onClicked(player) --this is the player instance from the event if model:FindFirstChild("Humanoid") ~= nil then if model.Humanoid:GetState() == Enum.HumanoidStateType.Dead then player.leaderstats.Coins.Value = player.leaderstats.Coins.Value + 1 --this will make the player earn 1 coin end end button.Regen:Play() end button.ClickDetector.MouseClick:Connect(onClicked)