Remote function returning empty tables

I’m making a custom backpack system for my game and the remote function / function that returns the backpack data returns empty tables. I have tested it and printed inside the function and it prints the table but when I print in local script it doesn’t. Thanks

-- Variables
local GetBackpack = game.ReplicatedStorage.Events.GetBackpack
local Players = game:GetService("Players")

-----------------------------------------------------------------
local function GetBackpackData(player)
	print(player)
	
	if player ~= nil then
		local MockPlayer = game.ServerStorage.Players:FindFirstChild(player.Name)
		local BackpackFolder = MockPlayer.BackpackFolder
		local Backpack = BackpackFolder:WaitForChild("Backpack")
		local Hotbar = BackpackFolder:WaitForChild("Hotbar")

		return Hotbar:GetChildren(), Backpack:GetChildren()
	else
		return nil
	end
	
end

GetBackpack.OnServerInvoke = GetBackpackData

Local script

-- Services
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

-- Events
local GetBackpack = game.ReplicatedStorage.Events.GetBackpack

-- Variables
local LocalPlayer = Players.LocalPlayer
local PlayerGUI = LocalPlayer.PlayerGui
local HotbarFrame = PlayerGUI.BackpackGui.HotbarFrame
local BackpackFrame = PlayerGUI.BackpackGui.BackpackFrame

----------------------------------------------------------------

local function GetHotbarPositions()
	print(LocalPlayer)
	local Hotbar, Backpack = GetBackpack:InvokeServer(LocalPlayer)
	print(Hotbar, Backpack)
end

GetHotbarPositions()

Idk why there is space after end in the first function

i did it myself but now uhghhhhhhhhhhhhhhhhhhhhhh aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa i got to make even more tables and for loops

Pain that is literal pain adding more tables and loops

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.