I'm doing the inventory GUI and it should render the objects, but it doesn't know what the inventory is! Here's the error.
13:58:10.632 - Players.HDWC.PlayerGui.MainHUD.HUD Handler:97: attempt to index upvalue 'inventory' (a nil value) 13:58:10.633 - Stack Begin 13:58:10.633 - Script 'Players.HDWC.PlayerGui.MainHUD.HUD Handler', Line 97 13:58:10.634 - Stack End
The local script
--VAIRIABLES local hud = script.Parent local inventory_frame = hud.Inventory local inventory_holder = inventory_frame.Inventory_Holder local inventory_search = inventory_frame.Search local inventory_x = inventory_frame.X local inventory = events.GetInventory:InvokeServer() local leftholder = script.Parent.LeftHolder local inventory_button = leftholder.Inventory local tab_opener = require(script["Tab Opener"]) --FUNCTIONS function renderinventory() local function renderobject(item_name) local frame = script.UiTemplate:Clone() frame.Title.Text = item_name local camera = Instance.new("Camera", frame) frame.CurrentCamera = camera local item = items:FindFirstChild(item_name):Clone() item.Parent = frame item:SetPrimaryPartCFrame(CFrame.new(0,0,0)) camera.CFrame = CFrame.new(Vector3.new(6,2,12), item.HitBox.Position) return frame end local objects = inventory:GetChildren() for _, v in pairs(objects) do local frame = renderobject(v.Name) frame.Parent = inventory_holder end end --STARTUP local signal = tab_opener:EnableObject(inventory_button, inventory_frame, UDim2.new(0.8,0,0.8,0), inventory_x) signal:Connect(renderinventory)
And finnally the server script:
--Vairiables local players = game:GetService("Players") local bases = workspace.Bases local items = game:GetService("ReplicatedStorage").Items local events = game:GetService("ReplicatedStorage").Events local dataservice = game:GetService("DataStoreService") local data = require(script.SaveData) local sstorage = game:GetService("ServerStorage") local pinventory = sstorage:WaitForChild("PlayerInventory") --Functions function get_base(Player) return bases.Base01 --[[ local returnvalue for _, v in pairs(bases:GetChildren()) do if v.Owned == nil or v.Owned == Player then returnvalue = v if v.Owned == nil then v.Owned = Player end return returnvalue end end --]] end function placeobject(player, location, model, base) local itemTemplate = items:FindFirstChild(model) if (itemTemplate) then local item = itemTemplate:Clone() item.Parent = base.ItemHolder item:SetPrimaryPartCFrame(location) end end function loadsave(plr) createinventory(plr) for i, v in pairs(data.Load(plr, get_base(plr))) do placeobject(plr, v[2], v[1], get_base(plr)) end end function createinventory(plr) local f = Instance.new("Folder", pinventory) f.Name = plr.Name return f end function get_inventory(plr) return pinventory.HDWC end --Startup --Triggers players.PlayerAdded:Connect(loadsave) players.PlayerRemoving:Connect(function(plr) data.Save(plr, get_base(plr)) end) events.GetBase.OnServerInvoke = function(plr) return get_base(plr) end events.GetInventory.OnServerInvoke = function(plr) return get_inventory(plr) end events.Place.OnServerEvent:Connect(function(plr, location,model, base) placeobject(plr, location,model, base) end)
Thanks in advance