Hello! Im trying to make a sandbox style game (Like miners haven) and Im trying to subtract 1 from the number of items in a players inventory! The following script runs when the player places an item. However it always has the error ServerScriptService.ServerPlacement:10: bad argument #2 to '?' (string expected, got Object) What can I do to fix this? (The value im calling at the end is an IntValue)
local items = game:GetService("ReplicatedStorage").Items
game:GetService("ReplicatedStorage").ClientPlaced.OnServerEvent:Connect(function(player, itemName, location)
local itemTemplate = items:FindFirstChild(itemName)
if (itemTemplate) then
local item = itemTemplate:clone()
item.Parent = workspace.Base.ItemHolder
item:SetPrimaryPartCFrame(location[1])
game.Players[player].PlayerGui.PlayerScreen.Inventory.ImageButton.TextLabel[itemName].value = game.Players[player].PlayerGui.PlayerScreen.Inventory.ImageButton.TextLabel[itemName].value - 1
end
end)
Also i tried it by doing it on the players end, however it subtracted 1 40-50 times!

1 comment
Thank you!