this script is for a gui that shows the players current cash. the players cash is a numbervalue named whatever the players username is, hence [player.name]. the local script is only getting one players cash value. so when Player1 has 100 cash and Player2 has 50 cash both of their GUI's say 100 cash. been at this for awhile and can't figure out a fix, any help is appreciated. (sorry for the title I literally have no idea how to word this question in one sentence)
--THE SERVER SCRIPT
local repStorage = game:GetService("ReplicatedStorage")
local remote = repStorage.remote
Players = game:GetService("Players")
while true do
wait(1)
for i, player in pairs(Players:GetPlayers()) do
cash = game.ServerStorage.PlayerMoney[player.Name]
cash.Changed:connect(function()
remote:FireClient(player, cash.Value)
end)
end
end
--THE LOCAL SCRIPT
local repStorage = game:GetService("ReplicatedStorage")
local remote = game.ReplicatedStorage:WaitForChild("remote")
wait(1)
local player = game.Players.LocalPlayer
local cashUpdate = player.PlayerGui.cashUpdate.Frame.TextLabel
remote.OnClientEvent:connect(function(cash)
cashUpdate.Text = "CASH: " .. cash
end)

1 comment
As I don't know how to explain it properly, read this post, there is a good answer -- https://scriptinghelpers.org/questions/72744/do-i-have-to-use-multiple-remote-events-to-give-a-player-multiple-items