Trying to retrieve a table through a remoteevent

Ive got a script to loop through a players inventory and create a table out of the items inside it and want to send this to the client to then do things based on if each item is owned rather than having to check and send for each item individually, I have created the table on the server which prints fine, but when it comes to the local script it doesnt retrieve it properly

This is my server script:
image

which prints this:
image

This is the local script: (can ignore most of it, just testing the table before doing anything with it)
image

Which prints this:
image
(which is what the table is originally set at in the serverscript)
Any idea how to load the table properly as im cleary doing something wrong

1 Like

Try firing the RemoteEvent after the for loop, not inside.

1 Like

same result when doing that

characters

1 Like

I’ve just realized I believe your item’s are in ServerStorage ?. If so, anything within ServerStorage and ServerScriptService, do not replicate to the client, try moving it to ReplicatedStorage.

1 Like

Ah thatll be why then, would it not be possible to print the results of the table as a string to send to the client? wont be able to change it to replicatedstorage without a lot of effort changing every script, would be easier though less organised to just check for each weapon individually by name and sending each one to the client

You could have a folder for the client in ReplicatedStorage, and parent a copy to that folder like:

for _, Item in ipairs(inventory1:GetChildren())do
    local clientItem = Item:Clone()
    clientItem.Parent = ReplicatedStorage > -- folder for the player, or just workspace if needed
    Inventory1Owned[Item.Name] = clientItem
end

You can also just parent the original without needing to clone if desired.

1 Like

Works good, thanks.

added this to remove them after the local script has done what it needs to do to stop exploiters being able to access the tools