I wanted to make an item drop from an inventory thingy when you press the imagebutton but for some reason it says “Argument 1 missing or nil” when i press the button,how can i fix it?
I tried looking on devforum but im kinda dumb so i wasnt able to understand anything
Here are the scripts:
LocalScript (inside the imagebutton)
local Button = script.Parent
local itemN = Button.Parent.Name.Text
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer
Button.Activated:Connect(function()
if workspace.Inventories[player.Name]:FindFirstChild(itemN).Value > 0 then -- Error there
ReplicatedStorage.Drop:FireServer(itemN)
else
end
end)
ServerScript
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
ReplicatedStorage.Drop.OnServerEvent:Connect(function(player,itemN)
if workspace.Inventories[player.Name] then
if workspace.Inventories[player.Name]:FindFirstChild(itemN) then
local ItemValue = workspace.Inventories[player.Name]:FindFirstChild(itemN)
if ItemValue.Value > 0 then
ItemValue.Value -= 1
local Clone = ServerStorage.Items[itemN]
Clone.Name = itemN
Clone.Parent = workspace
Clone.Position = player:FindFirstChild("HumanoidRootPart").Position
end
end
end
end)
Thanks in advance