Leaderstat shows "0" for server, except player's client

So basically, when a person interacts/clicks on a brick, he gets 0.1 “Bux”, ive made a leaderstat that shows other’s “Bux” amount, the person who clicked on brick has got 0.1 “Bux” on his leaderstat, meanwhile for other people, it shows “0”.

server script

Players.PlayerAdded:Connect(function(player)
	local leaderstatsFolder = Instance.new("Folder", player)
	leaderstatsFolder.Name = 'leaderstats'
	
	local Bux = Instance.new("NumberValue", player)
	Bux.Name = 'Bux'
	local leaderstatBux = Instance.new("StringValue", leaderstatsFolder)
	leaderstatBux.Name = 'Bux'
	leaderstatBux.Value = MoneyLib.DealWithPoints(Bux.Value)
-- as you can see, im using 2 values, one is for leaderstat (basically abbreviates huge numbers) and one for purchases/upgrades
end)

local script

ProxPrompt.Triggered:Connect(function()
		if db == false then
			db = true
		    Bux.Value += MoneyPerClick.Value -- this one line :/
			leaderstatBux.Value = MoneyLib.DealWithPoints(Bux.Value)
-- other lines dont cause the issue

You are changing the value using a LocalScript whom changes do not replicate to the server. You must change the value on the server using a Script.

1 Like

A LocalScript only interacts with the client it is run from. Changing the a value inside of a LocalScript only changes it for the user in which the LocalScript was run from. You will need to run the code inside of a Script instead!

you should use remote event for local script

server script

local RemoteEvent = game.ReplicatedStorage.RemiteEvent —remote event here
RemoteEvent.OnServerEvent:Connect(function(plr, Amount)
plr:FindFirstChild(“Bux”).Value += Amount

local script

local RemoteEvent = game.ReplicatedStorage.RemiteEvent —remote event here
ProxPrompt.Triggered:Connect(function()
if not db then
db = true
RemoteEvent:FireServer(MoneyPerClick.Value)