"Argument 1 missing or nil"

If you want I can send you my code for a system that does that

1 Like

Please do

you could just change what is in the frame

Also I cant give you my code because roblox studio is bugging out rn and it wont let me access places from other games. The entire asset manager just does not seem to work today

oh, so what should we do?

You should try to learn more about how to make systems like this. Watch some tutorials and see how they do things. Then try to make your own system

Do you know any good YouTube tutorials or something?

Is it possible to see the code now?

Sure, but rn I am unsure how to put it in a code box on the dev forums

what do you mean? Can you just put when you update /save the gui?

can i see when the gui is updated?

@SlinkyShelf0 you can do that by using the ` marks around ur code or pressing the </> button

1 Like
local function LoadSlot(ItemSlot, SlotFrameData)
	--Setting Variables
	local ItemName = ItemSlot.ItemName
	local IsEmpty = ItemName == ""
	local SlotItemData = Items[ItemName]
	
	local ItemFrame = SlotFrameData.Gui.ItemFrame
	local OldModel = ItemFrame.VP.Camera:FindFirstChild("Model")
	
	--Setting ViewportFrame Model
	if SlotFrameData.ItemName ~= ItemName then
		SlotFrameData.ItemName = ItemName
		
		--Getting Rid of Old Model
		if OldModel then
			OldModel:Destroy()
		end
		
		--Creating new Model
		if not IsEmpty then
			local newModel = SlotItemData.Model:Clone()
			newModel:SetPrimaryPartCFrame(CFrame.fromOrientation(0, 45, 0))
			newModel.Parent = ItemFrame.VP.Camera
		end
	end
	
	--Setting QuanitityLabel
	local ItemQuantity = ItemSlot.Quantity
	if not IsEmpty and SlotItemData.Stackable then
		ItemFrame.Quantity.Visible = true
		if SlotFrameData.Quantity ~= ItemQuantity then
			ItemFrame.Quantity.Text = ItemQuantity
			SlotFrameData.Quantity = ItemQuantity
		end
	else
		ItemFrame.Quantity.Visible = false
	end
end

This is the function that I call to update all the slots

would this be fired by a remote event? or stay inside of the local script?

I have a function that tells the client when their data has been changed so my code listens to that and calls this function when it does

local function UpdateInventory()
	for i, v in pairs(PlayerData.SlotData.Inventory) do
		LoadSlot(
			PlayerData.SlotData.Inventory[i],
			InventorySlotFrameData[i]
		)
	end
	for i, v in pairs(PlayerData.SlotData.HotBar) do
		LoadSlot(
			PlayerData.SlotData.HotBar[i],
			HotBarSlotFrameData[i]
		)
	end
end

and what is the old model thing?

To display the item my code uses a viewport frame. When we want to change which item it is displaying we first have to get rid of the old one

He is resetting the slots so if there is anything in the old inventory slots he wants to get rid of it.