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

Why won't the int value(wood) go into the player folder Inventory?

Asked by 5 years ago
Edited 5 years ago

Yes other dumb question but the int value (wood) won't go into the inventory

here's the script

01script.Parent.ClickDetector.MouseClick:Connect(function(player)
02    if(player.Inventory:FindFirstChild("Wood")) then
03        player.Inventory:WaitForChild("Wood").Value = player.Inventory:WaitForChild("Wood").Value +1
04    elseif (not player.Inventory:FindFirstChild("Wood")) then
05        local wood = Instance.new("IntValue", player)
06        wood.Name = "Wood"
07        wood.Value = 1
08    end
09    script.Parent.Parent:Destroy()
10end)

and there's no error in the output

1
You're parenting the IntValue to the player not the inventory. Narunzo 172 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

You set the wood's parent to the player, not the Backpack. Also, you're supposed to use "Backpack", not "Inventory." Try this:

01script.Parent.ClickDetector.MouseClick:Connect(function(player)
02    if(player.Backpack:FindFirstChild("Wood")) then
03        player.Backpack:WaitForChild("Wood").Value = player.Backpack:WaitForChild("Wood").Value +1
04    elseif (not player.Backpack:FindFirstChild("Wood")) then
05        local wood = Instance.new("IntValue")
06        wood.Name = "Wood"
07        wood.Value = 1
08    wood.Parent = player.Backpack
09    end
10    script.Parent.Parent:Destroy()
11end)
0
I'm making a inventory gui Eric_pokemon 133 — 5y
0
my bad for not saying that beforehand Eric_pokemon 133 — 5y
0
but this solution does work Eric_pokemon 133 — 5y
0
if you replace the backpack to Inventory Eric_pokemon 133 — 5y
Ad

Answer this question