Ah.
Something very fundamental about the Roblox server/client paradigm that I didn’t get is that ALL player data set on the server is automatically propagated to each client.
So, if you do something like this on the server:
local players = game:GetService("Players")
players.PlayerAdded:Connect(function(player)
local myFolderInstance = Instance.new("Folder")
myFolderInstance.Name = "AnyFolderNameYouLike"
myFolderInstance.Parent = player
local myValueInstance = Instance.new("IntValue")
myValueInstance.Name = "AnyValueNameYouLike"
myValueInstance.Value = 100
myValueInstance.Parent = myFolderInstance
spawn(function()
while true do
wait(2)
myValueInstance.Value = myValueInstance.Value + 100
end
end)
end)
Then you can do something like this in each client:
while true do
wait(2)
local Players = game:GetService("Players")
for _, player in pairs(Players:GetPlayers()) do
local folderInstance = player:FindFirstChild("AnyFolderNameYouLike")
if folderInstance then
print(player.Name .. ': ' .. folderInstance.AnyValueNameYouLike.Value)
end
end
end
And you will see the updated values as set on the server (for each player) get printed out on the client also updated.
BUT of course in a real game you would not loop through the values like that you would bind to change events for the folder such as GetPropertyChangedSignal. IE Something like this:
local player = game.Players.LocalPlayer
player.AnyFolderNameYouLike.AnyValueNameYouLike:GetPropertyChangedSignal("Value"):Connect(function()
print(player.AnyFolderNameYouLike.AnyValueNameYouLike.Value)
end)
Hopefully this will help someone else who didn’t understand the basic Roblox propagation paradigm.
For all you native Roblox coders out there, something like this is kind of magical and doesn’t happen in many other languages - you often have to code it yourself.