player = workspace.Parent.Players.LocalPlayer.Name while true do wait(1) cash = workspace.Parent.Players..player.Backpack.DataFolder.Currency.Value script.Parent.Parent.Counter.Text = cash end
This is just a simple piece of code that I ripped from my script. I'm trying to constantly update a value for multiple players, so I can't use localplayer.
I have no Idea how to do this, and if anybody can show me how I can do this I would greatly appreciate it!
I would assume from your code you are trying to update a GUI to show each players money.
I wrote this that goes through each player in the game and if the DataFolder is loaded then updates the TextBox GUI that the is the scripts parent to show the players currency. For 1 second and then show the next players and so on.
I put this code in a server script as a child to the TextBox, you will need to use a server script if you want to be able to read all players currency.
local Players = game:GetService("Players") while true do for _, player in pairs(Players:GetPlayers()) do if player.Backpack:FindFirstChild("DataFolder") then local cash = player.Backpack:FindFirstChild("DataFolder").Currency.Value script.Parent.Text = cash wait(1) end end wait(1) end