Coin Script:
local coin = script.Parent
local function onTouch(hit)
local character = hit.Parent
local player = game.Players:GetPlayerFromCharacter(character)
if player then
local leaderstats = player:FindFirstChild("leaderstats")
local coins = leaderstats and leaderstats:FindFirstChild("Coins")
if coins then
coins.Value = coins.Value + 1
end
coin:Destroy()
end
end
coin.Touched:Connect(onTouch)
Leaderboard Script:
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local coins = Instance.new("IntValue")
coins.Name = "Coins"
coins.Value = 0
coins.Parent = leaderstats
end)