Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

My Inventory System adds multiple items and not just one, why is that?

Asked by 10 years ago

Basically, I have got the Inventory System to work pretty darn well. When the player presses E on their keyboard the item is then removed from the world and put into their inventory. The problem is that when the item is picked up, multiple quantitys of that time is added and not just one. It should add 1 item and not like 6.

01local player = game:GetService("Players").LocalPlayer
02local char = player.Character
03local mouse = player:GetMouse()
04local inv_gui = script.Parent.Inventory
05local inv = player:WaitForChild("Inventory")
06 
07while wait(0.1) do
08    for _,item in pairs(workspace["WinterSurvival"].DroppedItems:GetChildren()) do
09        if (item:IsA("Model")) then
10            local itemID
11            function findID(par)
12                for _,kid in ipairs(par:GetChildren()) do
13                    if (kid:IsA("Model")) then
14                        itemID = kid.ItemID.Value
15                    else
View all 57 lines...
  • Thanks
0
Did you ever get this fixed? I'm looking through your post history and noticed this had no answers. adark 5487 — 10y

1 answer

Log in to vote
0
Answered by
ZeroBits 142
9 years ago

on line 27, change

1and debounce

to

1and debounce == true

this should fix things.

Why should this work?

well, when you say; "if value then" you're saying "if this value is not Nil then do this", now, false isn't nil, it's an actual value, so you have to say either "if value == true" or "if value ~= false" to get the desired result, depending on how strict you want to be with the script.

Ad

Answer this question