I want an ArrayValue in the explorer bar so I can make a dictionary. I considered making a folder and putting multiple folders in that folder to emulate a dictionary but I would like a more efficient way so I dont have to use RemoteEvents to send information to the server then to the client then back to the server and then the player
Making folders in your explorer could be working since they’re automatically replicated and the values in the folders could be a Value object which is also automatically replicated. I’m pretty sure these Value objects are optimized and their value is replicated/synchronized only when the value is changed by the server.
However if you wanna keep the data in one place (as you mentioned ArrayValue), you could just add a StringValue and serialize your array into JSON. Unfortunate you’d have to make some postprocessor if you wanna use the values in such array directly.
HttpService will help you with serialization and deserialization, but the postprocessor with caching and other features is on you.
This definitely sounds like it would work. Thank you
remote events are the most efficient way to send data over the network
-- server script
local sharedTable = {}
game.Players.PlayerAdded:Connect(function(player)
sharedTable[player] = {}
end)
game.Players.PlayerRemoving:Connect(function(player)
sharedTable[player] = nil
end)
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(player, key, value)
sharedTable[player][key] = value
end)
local function Get(player, key)
return sharedTable[player][key]
end
local function Set(player, key, value)
game.ReplicatedStorage.RemoteEvent:FireClient(player, key, value)
sharedTable[player][key] = value
end
-- local script
local sharedTable = {}
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function(key, value)
sharedTable[key] = value
end)
local function Get(key)
return sharedTable[key]
end
local function Set(key, value)
game.ReplicatedStorage.RemoteEvent:FireServer(key, value)
sharedTable[key] = value
end