Not visible leaderstats

I was trying to make a game with leaderstats and a string value, and it didn’t go well.
When I tested the game with multiple players, it looked like not I wanted to be and the string value(the one on the right) only appears to the player, not all. Here’s a picture:


(not real money)

I appreciate any help and the reason is that I have played a game with string values visible to everyone.

Is the value of the leaderstat set on the server or the client?

its set on a GUI change like this(localscript)

local FormatNumber = require(game.Workspace.FormatNumber.Main)
local formatter = FormatNumber.NumberFormatter.with()
local plr = game.Players.LocalPlayer
local robux = plr:WaitForChild("Values"):WaitForChild("Robux") -- Change to your currency name
local displayRobux = plr:WaitForChild("leaderstats"):WaitForChild(" Robux")

-- Add your abbreviations/compact notation suffixes here
local abbreviations = FormatNumber.Notation.compactWithSuffixThousands({
	"K", "M", "B", "T", "aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai", "aj", "ak", 'al', "am",
	"an", "ao", "ap", "aq", "ar", "as", "at", "au", "av", "aw", "ax", "ay", "az", "ba", "bb", "bc", "bd",
	"be", "bf", "bg", "bh", "bi", "bj", "bk", "bl", "bm", "bn", "bo", "bp", "bq", "br", "bs", "bt", "bu", "bv",
	"bw", "bx", "by", "bz", "ca", "cb", "cc", "cd", "ce", "cf", "cg", "ch", "ci", "cj", "ck", "cl", "cm", "cn",
	"co", "cp", "cr", "cs", "ct", "cu", "cv", "cw", "cx", "cy", "cz", "da", "db", "dc", "dd", "de", "df", "dg", "dh", "di",
	"dj", "dk", "dl", "dm", "dn", "do", "dp", "dq", "dr", "ds", "dt" -- Change these to whatever formats you want
})
local formatter = FormatNumber.NumberFormatter.with()
	:Notation(abbreviations)
    Precision.maxFraction(1) to round it to 1 decimal place
	:Precision(FormatNumber.Precision.integer():WithMinDigits(3))

local text = formatter:Format(robux.Value)
displayRobux.Value = text
script.Parent.Text = "$"..text

robux.Changed:Connect(function()
	local text = formatter:Format(robux.Value)
	displayRobux.Value = text
	script.Parent.Text = "$"..text
end)

use serverscript whenever u deal with leaderstats

The picture to the right is showing a zero … if that was a string it would look blank.
Unless you made it a string “0”.

how do i get the player in the server script

game:GetService("Players").PlayerAdded:Connect(function(PlrWhoJoined)
	
end)

this fires whenever a player joined the game, and since this will be handled by the server (assuming u wont put any wait() above it) it will automatically watch out for incoming players before anyone else join

local Players=game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
	-- this part is on spawn only
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local stat = Instance.new("StringValue")
	stat.Name = "TestStat"
	stat.Parent = leaderstats
	
	player.CharacterAdded:connect(function(character)
		-- this part is on spawn and respawns
		
	end)	
end)

There are other ways to do this but, this way is hard to beat. Everything you need within a few lines as far as a server script dealing with the player/character.

I tried.

game.Players.PlayerAdded:Connect(function(plr)
	local FormatNumber = require(game.Workspace.FormatNumber.Main)
	local formatter = FormatNumber.NumberFormatter.with()
	local robux = plr:WaitForChild("Values"):WaitForChild("Robux") -- Change to your currency name
	local displayRobux = plr:WaitForChild("leaderstats"):WaitForChild(" Robux")

	-- Add your abbreviations/compact notation suffixes here
	local abbreviations = FormatNumber.Notation.compactWithSuffixThousands({
		"K", "M", "B", "T", "aa", "ab", "ac", "ad", "ae", "af", "ag", "ah", "ai", "aj", "ak", 'al', "am",
		"an", "ao", "ap", "aq", "ar", "as", "at", "au", "av", "aw", "ax", "ay", "az", "ba", "bb", "bc", "bd",
		"be", "bf", "bg", "bh", "bi", "bj", "bk", "bl", "bm", "bn", "bo", "bp", "bq", "br", "bs", "bt", "bu", "bv",
		"bw", "bx", "by", "bz", "ca", "cb", "cc", "cd", "ce", "cf", "cg", "ch", "ci", "cj", "ck", "cl", "cm", "cn",
		"co", "cp", "cr", "cs", "ct", "cu", "cv", "cw", "cx", "cy", "cz", "da", "db", "dc", "dd", "de", "df", "dg", "dh", "di",
		"dj", "dk", "dl", "dm", "dn", "do", "dp", "dq", "dr", "ds", "dt" -- Change these to whatever formats you want
	})
	local formatter = FormatNumber.NumberFormatter.with()
		:Notation(abbreviations)
		-- Round to whichever results in longest out of integer and 3 significant digits.
		-- 1.23K  12.3K  123K  4.56T  45.6T  456T  7.89ag  78.9ag  789ag
		-- If you prefer rounding to certain decimal places change it to something like Precision.maxFraction(1) to round it to 1 decimal place
		:Precision(FormatNumber.Precision.integer():WithMinDigits(3))

	local text = formatter:Format(robux.Value)
	displayRobux.Value = text
	plr.PlayerGui.Game.RobuxBackground.RobuxDisplay.Text = ""..text - error

	robux.Changed:Connect(function()
		local text = formatter:Format(robux.Value)
		displayRobux.Value = text
		plr.PlayerGui.Game.RobuxBackground.RobuxDisplay.Text = ""..text -- error
	end)
end)

It gave me error: Game is not a valid member of PlayerGui "Players.ElectricPeaPvZ.PlayerGui"

EDIT: THANKS FOR ALL YOUR HELP! I CHANGED IT TO SET THE UI IN LOCALSCRIPT AND STRING IN SERVERSCRIPT! It works!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.