Collectible Coins with Timed Return thumbnail
0 views0 copies0 likes

Collectible Coins with Timed Return

Universal script

Copy it, then test it in your own Studio place.

Utilities Verified

Script code

17 lines · 0.6 KB
Download
local Players = game:GetService("Players")for _, coin in workspace:WaitForChild("CoinPickups"):GetChildren() do	if not coin:IsA("BasePart") then continue end	local enabled = true	local opacity = coin.Transparency	coin.Touched:Connect(function(hit)		local character = hit:FindFirstAncestorOfClass("Model")		local player = character and Players:GetPlayerFromCharacter(character)		if not enabled or not player then return end		enabled = false		player:SetAttribute("Coins", (player:GetAttribute("Coins") or 0) + 1)		coin.Transparency = 1		task.wait(6)		coin.Transparency = opacity-- …open Get script for the full source

About this script

Put anchored coin parts in a folder named Workspace.CoinPickups. The script awards one point to a player's Coins attribute per pickup, hides the collected coin, then restores it after six seconds for everyone. One availability flag per coin prevents double payouts from overlapping touches. Connect a UI to the Coins attribute if you want to show the session balance.

Comments

Share what works, ask questions, or report an issue.

0

Log in to leave a comment.

No comments yet

Be the first to share your thoughts!

Raw Luau source

local Players = game:GetService("Players")
for _, coin in workspace:WaitForChild("CoinPickups"):GetChildren() do
	if not coin:IsA("BasePart") then continue end
	local enabled = true
	local opacity = coin.Transparency
	coin.Touched:Connect(function(hit)
		local character = hit:FindFirstAncestorOfClass("Model")
		local player = character and Players:GetPlayerFromCharacter(character)
		if not enabled or not player then return end
		enabled = false
		player:SetAttribute("Coins", (player:GetAttribute("Coins") or 0) + 1)
		coin.Transparency = 1
		task.wait(6)
		coin.Transparency = opacity
		enabled = true
	end)
end