Argument 1 missing or nil

I wanted to make an inventory system,i put the whole script in there but when i run it it says “Argument 1 missing or nil”
How can i fix it?
The error in the script is only in the drop event,but i put the whole script,its marked down though.

	local PlrInv ="Folder")
	PlrInv.Name = (player.UserId .. player.Name) 
	PlrInv.Parent = workspace.Inventories

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")

	local HRP = player.Character:WaitForChild("HumanoidRootPart")
	local MaxDistance = player.PlayerGui.PickupGui.MaxDistance
	if (HRP.Position - item.Position).Magnitude < MaxDistance then
		if workspace.Inventories[player.UserId .. player.Name]:FindFirstChild(item.Name) then
			workspace.Inventories[player.UserId .. player.Name][item.Name].Value += 1
			player.PlayerGui.Inventory.Frame[item.Name].ItemCount.Text = workspace.Inventories[player.UserId .. player.Name][item.Name].Value
		elseif not workspace.Inventories[player.UserId .. player.Name]:FindFirstChild(item.Name) then
			local NewItem ="IntValue",workspace.Inventories[player.UserId .. player.Name])
			NewItem.Name = item.Name
			NewItem.Value = 1
			local NewItemGui = ServerStorage.Assets.Gui.Template:Clone()
			NewItemGui.Name = item.Name
			NewItemGui.ItemCount.Text = 1
			NewItemGui.ItemName.Text = item.Name
            NewItemGui.Parent = player.PlayerGui.Inventory.Frame

ReplicatedStorage.Inv.Drop.OnServerEvent:Connect(function(player,item) -- When the player presses the drop button it fires
	local playerinv = workspace.Inventories[player.UserId .. player.Name] -- Gets the player inventory
	if workspace.Inventories[player.UserId .. player.Name]:FindFirstChild(item.Name) then -- Error here
		local itemi = playerinv[item.Name]
		if itemi.Value > 0 then
			itemi.Value -= 1
			local DropItem = ServerStorage.Items[item.Name]:Clone()
			DropItem.Parent = workspace
			DropItem.Position = player.Character.HumanoidRootPart.Position +,3,0)

Thanks in advance.

If this is the error, it could be because item.Name returned a nil or no value assigned to it, meaning argument 1 missing or you passed in a nil argument. Try printing item and item.Name

Its nil for some reason,idk why
here’s the localscript of the button

local InventoryEvents = game:GetService("ReplicatedStorage").Inv
local Button = script.Parent
local item = Button.Parent.Name

If the item only exist in the client then of course it’s going to be nil when being fired to the server.

Instead of passing in the item which is a type of instance, you could just use the name instead which is better so you could check on the server side if the item name exist if not you could warn the player he/she could be exploiting.

I may have not understood you but
The client sends the item name,not the item.

Then why are you still using .Name on a string?
You are sending a type of string to the server, you don’t have to use .Name, this is only applicable for tables.

1 Like

I think i dont understand,im sending Button.Parent.Name,the Frame that is the Parent of the button is named after the item

Oh,i got it,i was using .Name in the serverscript