Accommodating for Multiple Stacks of Items in an Inventory System

Like all the function calls, but not the functions themselves

No that was just my example, essentially you would only call them when needed.

I have this code format which was used to add items before. Could this be left intact or does anything have to change?

local Info = {
	Item1 = "Bucket",
	Num1 = 1,
}
script.Parent.Triggered:Connect(function(player)
	script.Parent.Enabled = false
	local PlayerID = player.UserId
	local Location = script
	
	game.ReplicatedStorage.Inventory.AddItemBindable:Fire(player, {
		Location = Location,
		PlayerID = PlayerID,
		Num1 = Info.Num1,
		Item1 = Info.Item1
	})

end)

Well, how you do it seems fine but you could definitely improve the naming structure of the data: “Item” instead of “Item1” and “Amount” instead of “Num1”. Also seems like “Location” is just the slot so rename it to smth like “SlotId”

I used Location so that the Inventory handler knows where the remote event was fired from, so then it can fire events inside that script which ill do things like delete the part, or return a certain amount if the inventory is overflowing.

Oh I c, I don’t suppose you have to change any of that since its tied to your game logic

Okay thanks. I need to figure out what to do now for finding the correct player inventory. Should I check for the UserId still or the name?

I actually set the index as the player instance since instances are pretty much unique but ye you can opt for UserId but don’t do name

Should this conversation be moved to DMs so this thread doesn’t continue to expand?

Absolutely, tho it’d be better if it was in discord rather than here in the forum

Okay that would work out. Send me your username

mystxryxd

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