but if i didn’t do serverstorage then the datastore2 script will break. I tried putting it in replicatedstorage but it said userid is not a valid member of armor
replicatedstorage.Events.UpdateInventory.OnClientEvent:Connect(function(player, armor, data)
-- Everything when the client recives this event | added Data to the parameter
end)
Essentially the data you are sending over is the players data, that way you wouldn’t need to access it from client, whenever you are working with data make sure its always on the server.
-- client
local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteFunction")
local inventoryData = remote:InvokeServer() -- get the inventory data
-- server
local remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteFunction") -- the remote function
local dataStore2 = require(ModuleScript) -- the data store 2 module script
remote.OnServerInvoke = function(player)
return dataStore2("Inventory", player) -- return the player's inventory data to the client
end
The client asks the server to get the player’s inventory data and return it to the client.
Also, I don’t use DataStore2 so I might mess up some things