My RemoteFunction isnt returning what i need

Im making a shop for my game. And to make a shop, i need to get information about the items to properly display them. The information is stored inside the ServerStorage and the shop is run in a LocalScript, so i need to use RemoteFunction to return some info. However, when it returns and i run a for loop on the variable, it seems like it returned nothing because print is not showing anything.

Heres my code:

-- Local script
local shopitems = game.ReplicatedStorage:WaitForChild("Remotes").GetWepStats:InvokeServer()

for i,v in pairs(shopitems) do
    print(v.Name)
end

-- Server script
game.ReplicatedStorage:WaitForChild("Remotes").GetWepStats.OnServerInvoke = function(p)
	local things = {}
	for i,v in pairs(game.ServerStorage.WeaponStats:GetChildren()) do
		local clone = v:Clone()
		table.insert(things, clone)
	end
	return things
end

“WeaponStats” is a folder that has more folders containing information about each item. The output does not print anything when the for loop is ran. Any ideas on what’s causing this?

Are there any errors/warns in the output?

No Errors, no warnings.

kind of hard to find warning because my output is constantly flooded with LoadLibrary stuff from my plugins.

Could you show me the WeaponStats folder?

This is all thats in the folder. The insides of the folder are just ModuleScripts

image

I don’t believe items that aren’t visible to the client can be sent to the client.

1 Like

Remember that ServerStorage and ServerScriptService contents are inaccessible to clients.

Thus, when attempting to pass a reference to a descendant of one of those services, the client will get nil. So theoretically you’ve passed an empty table to the client. Also you never parent the clones anywhere.

5 Likes

Yup. I parented the clones to ReplicatedStorage and that fixed it. Thanks