Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

here's the script

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	if(player.Inventory:FindFirstChild("Wood")) then
		player.Inventory:WaitForChild("Wood").Value = player.Inventory:WaitForChild("Wood").Value +1
	elseif (not player.Inventory:FindFirstChild("Wood")) then
		local wood = Instance.new("IntValue", player)
		wood.Name = "Wood"
		wood.Value = 1
	end
	script.Parent.Parent:Destroy()
end)

and there's no error in the output

1 comment

1

You're parenting the IntValue to the player not the inventory.

1 answer

✓ Accepted answer

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

script.Parent.ClickDetector.MouseClick:Connect(function(player)
    if(player.Backpack:FindFirstChild("Wood")) then
        player.Backpack:WaitForChild("Wood").Value = player.Backpack:WaitForChild("Wood").Value +1
    elseif (not player.Backpack:FindFirstChild("Wood")) then
        local wood = Instance.new("IntValue")
        wood.Name = "Wood"
        wood.Value = 1
	wood.Parent = player.Backpack
    end
    script.Parent.Parent:Destroy()
end)

4 comments

0

I'm making a inventory gui

0

my bad for not saying that beforehand

0

but this solution does work

0

if you replace the backpack to Inventory

This discussion is preserved as it was. New answers, comments, and votes are closed.