Hello,
I wanted to make a dropping system for my inventory.
It works perfect besides of these blocks of code.
It gives me theis type of errors:
ServerScriptService.PickUpItem:45: attempt to index nil with ‘Clone’
The 2 different script for the RemoteFunction are below.
I hope anyone can help.
for i, itemButton in pairs(InventoryGui.ItemList:GetDescendants()) do
-- Right Click
if itemButton:IsA("TextButton") then
itemButton.MouseButton1Click:Connect(function()
local itemFrame = itemButton.Parent
local itemValue = Inventory:FindFirstChild(itemFrame.Name)
if itemValue.Value > 0 then
local DropItem = DropItem:InvokeServer(itemFrame.Name)
if DropItem == true then
if itemValue.Value > 0 then
itemFrame.Quantity.Text = itemValue.Value
else
itemFrame.Visible = false
end
end
end
end)
end
end
DropItem.OnServerInvoke = function(player, ItemName)
local Inventory = player.Inventory
local item = Inventory:FindFirstChild(ItemName)
if item then
if item.Value > 0 then
item.Value = item.Value - 1
local itemClone = item:FindFirstChild(ItemName):Clone()
itemClone.CFrame = player.Character.HumanoidRootPart.CFrame + player.Character.HumanoidRootPart.CFrame.LookVector * 6
itemClone.Parent = game.Workspace
return true
else
return false
end
end
end