I’m trying to send an inventory from a datastore in a script to where it is used, in a LocalScript. I’m at a loss as to why I cant send this dictionary from the server to the client without it appearing as nil.
--LocalScript rs = game:GetService("ReplicatedStorage") remote = rs:WaitForChild("SendData") data = { ownedcolours = {"White"}, ownedfaces = {"Raig"}, ownedgloves = {"Red"}, ownedhats = {} } local function datafound(player, data) data = data print(data) end remote.OnClientEvent:connect(datafound)
–Script in ServerScriptService
local ds = game:GetService(“DataStoreService”)
local datastore = ds:GetDataStore(“InventorySaveSystem”)
local rs = game:GetService(“ReplicatedStorage”)
local remote = rs:WaitForChild(“SendData”)
game.Players.PlayerAdded:connect(function(player)
local sentdata = datastore:GetAsync(player.UserId) or {
ownedcolours = {“White”},
ownedfaces = {“Raig”},
ownedgloves = {“Red”},
ownedhats = {}
}
datastore:SetAsync(player.UserId, sentdata)
remote:FireClient(player, sentdata)
end)
any help would be great, sorry if the formatting is terrible and/or my code is hard to read, I’ve never tried to ask for help before