Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

remote event sending same players cash value to every player?

this script is the server side script for a gui that says what the players cash is. the variable "cash" is set to only one persons cash value and therefore everyone's cash gui shows as how much cash that one person has

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] --the players cash.Value
	cash.Changed:connect(function() 
		remote:FireClient(player, cash.Value)
	end)
end

end

1 answer

You did the for loop wrong put _, before the variable

01	local repStorage = game:GetService("ReplicatedStorage")
02	local remote = repStorage.remote
03	 
04	Players = game:GetService("Players")
05	 
06	while true do
07	    wait(1)
08	    for _,player in pairs(Players:GetChildren())
09	       cash = game.ServerStorage.PlayerMoney[player.Name] --the players cash.Value
10	    cash.Changed:connect(function()
11	        remote:FireClient(player, cash.Value)
12	    end)
13	end
14	 
15	end

This discussion is preserved as it was. New answers, comments, and votes are closed.