Roblox coin script (collect and respawn)

Coins players collect by touching them: +1 on the leaderboard, the coin disappears, then comes back. One script handles every coin in the map.

ScriptUpdated November 2, 2026

Where to put it

Script — ServerScriptService > Coins (Script). It runs on the server, so players can't change what it does.

  1. Make a coin (a yellow Cylinder, anchored, CanCollide off) and tag it Coin (Properties → Tags). Duplicate it around the map.
  2. Players need leaderstats > Coins — the leaderboard script creates it.

The script

ServerScriptService > Coins (Script)
local Players = game:GetService("Players")
local CollectionService = game:GetService("CollectionService")

local VALUE = 1
local RESPAWN_SECONDS = 10

local function setupCoin(coin)
	local collected = false
	coin.Touched:Connect(function(hit)
		if collected then return end
		local player = Players:GetPlayerFromCharacter(hit.Parent)
		if not player then return end
		local coins = player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Coins")
		if not coins then return end

		collected = true
		coins.Value += VALUE
		coin.Transparency = 1
		coin.CanTouch = false
		task.wait(RESPAWN_SECONDS)
		coin.Transparency = 0
		coin.CanTouch = true
		collected = false
	end)
end

for _, coin in CollectionService:GetTagged("Coin") do
	setupCoin(coin)
end
CollectionService:GetInstanceAddedSignal("Coin"):Connect(setupCoin)

How it works

  • Tags let one script control every coin — duplicate coins freely without copying scripts.
  • collected and CanTouch = false make sure each coin pays once, even if several body parts touch it.
  • The coin is hidden, not destroyed, so it can come back after RESPAWN_SECONDS.

Variations

Spinning coins

Spin them on the client so the server does no extra work: a LocalScript in StarterPlayerScripts that rotates every tagged coin a little each RenderStepped.

Pickup sound

Put a Sound in the coin and call coin.Sound:Play() right after adding the value.

Common mistakes

  • Giving coins from a LocalScript — the server never sees it and the value resets.
  • No debounce: one touch pays 5–10 times as each body part hits the coin.
  • Leaving CanCollide on, so players bump into coins instead of collecting them.

FAQ

Why do my coins give more than 1 at a time?

Several body parts touch the coin in the same moment. Use a flag or set CanTouch to false right after the first touch, as this script does.

How do I make coins save?

Save the Coins value with a data store on leave and load it on join — see the data store script.

Keep reading