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()