Coin Leaderstats from Player Attributes thumbnail
0 views0 copies0 likes

Coin Leaderstats from Player Attributes

Universal script

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

Utilities Verified

Script code

18 lines · 0.6 KB
Download
local Players = game:GetService("Players")local function bind(player)	local stats = player:FindFirstChild("leaderstats")	if not stats then		stats = Instance.new("Folder", player)		stats.Name = "leaderstats"	end	local coins = stats:FindFirstChild("Coins")	if not coins then		coins = Instance.new("IntValue", stats)		coins.Name = "Coins"	end	local function sync() coins.Value = math.floor(player:GetAttribute("Coins") or 0) end	player:GetAttributeChangedSignal("Coins"):Connect(sync)-- …open Get script for the full source

About this script

Use this server Script to display your session Coins attribute on Roblox's player list. It creates or reuses the leaderstats folder, then updates its Coins IntValue whenever the attribute changes. Other systems can award points by writing the attribute, while this script handles display only. Test a new player and an existing coin pickup together to check that the display follows each award.

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")
local function bind(player)
	local stats = player:FindFirstChild("leaderstats")
	if not stats then
		stats = Instance.new("Folder", player)
		stats.Name = "leaderstats"
	end
	local coins = stats:FindFirstChild("Coins")
	if not coins then
		coins = Instance.new("IntValue", stats)
		coins.Name = "Coins"
	end
	local function sync() coins.Value = math.floor(player:GetAttribute("Coins") or 0) end
	player:GetAttributeChangedSignal("Coins"):Connect(sync)
	sync()
end
Players.PlayerAdded:Connect(bind)
for _, player in Players:GetPlayers() do bind(player) end