Roblox coin pickup script
Coins to collect: touch one to add it to your stat, and it comes back after a few seconds. One script runs every coin in the folder.
Where it goes
- 1It adds to a stat called Coins: add the leaderboard script too, so players have one.
- 2Add a Folder to Workspace and name it Coins. Put your coin Parts in it, with Anchored on and CanCollide off.
- 3In the Explorer, hover over ServerScriptService, press +, choose Script and paste this in.
-- From forja.us/tools/roblox-scripts/coin-pickup-- Touch a coin to collect it. It comes back after a few seconds.local Players = game:GetService("Players")local VALUE = 1local BACK_AFTER_SECONDS = 10local coins = workspace:WaitForChild("Coins")local function setUpCoin(coin) local taken = false coin.Touched:Connect(function(hit) if taken then return end local character = hit:FindFirstAncestorOfClass("Model") local player = character and Players:GetPlayerFromCharacter(character) local leaderstats = player and player:FindFirstChild("leaderstats") local stat = leaderstats and leaderstats:FindFirstChild("Coins") if not stat then return end taken = true stat.Value += VALUE coin.Transparency = 1 task.wait(BACK_AFTER_SECONDS) coin.Transparency = 0 taken = false end)endfor _, coin in coins:GetChildren() do if coin:IsA("BasePart") then setUpCoin(coin) endendHow it works
- The loop gives each coin its own
Touched, so they don't need a script each. takenstops one coin counting twice, because touching can fire several times at once.- It runs on the server, so players can't give themselves coins from their own device.
Make it yours
- Worth more
- Change
VALUE. - Gone for good
- Replace the lines after
stat.Value += VALUEwithcoin:Destroy().
Maps to try it on: simulator and tycoon maps
Start from a finished map, and your scripts have a game to run in.
More free Roblox scripts
Roblox kill brick scriptRoblox leaderboard scriptRoblox save data scriptRoblox sprint scriptRoblox double jump scriptRoblox teleport scriptRoblox obby checkpoint scriptRoblox day and night cycle scriptRoblox game pass scriptRoblox developer product scriptRoblox door scriptRoblox tool giver scriptRoblox round system scriptRoblox background music scriptRoblox speed pad scriptRoblox jump pad scriptRoblox VIP door scriptRoblox daily reward scriptRoblox NPC dialogue scriptRoblox pet follow scriptRoblox gun scriptRoblox admin commands scriptRoblox tycoon dropper scriptRoblox shop GUI script

