Inventory System issues

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve?
    I am trying to make it so if it doesn’t find a configuration with the same name it will fire client on a remote.

  2. What is the issue?


    There is no same configuration with the same name so it only shows up for the first child which is added

  3. What solutions have you tried so far?
    I had a script which looped through the backpack but it wasn’t so good.

-- // Services
local ServerScriptService = game:GetService("ServerScriptService")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Player = game:GetService("Players")
-- //
local Inventory = {}

function AddItem(plr, Child)
	plr.PlayerGui:WaitForChild("RobloxCore"):WaitForChild("MiniBarContainer"):WaitForChild("Events"):WaitForChild("ClientEvent"):FireClient(plr, Child)
end

Player.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function()
		-- // Variables
		plr.Backpack.ChildAdded:Connect(function(Child)
			if Child:IsA("Configuration") then
				Child.Name = Child.Name.."_"..Child:WaitForChild("Type").Value
				if #plr.Backpack:GetChildren() == 1 then
					AddItem(plr, Child)
					print("Received!")
				else
					if not plr.Backpack:FindFirstChild(Child.Name) then
						print(Child.Name.."_Received")
						AddItem(plr, Child)
					else
						print(Child.Name.."_Notreceived")
					end
				end
			else
				return
			end
		end)
	end)
end)


return Inventory
1 Like