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

How can i get player's inventory in local script?

Umm.I mean, ****I made a local script inside a tool and type this codes.

player = game.Players.LocalPlayer
tool = script.Parent
tool.Equipped:connect(function(mouse)

mouse.KeyDown:connect(function(key)
	if key == "h" then
		print("You pressed h")
	else
		
		end
end)
end)

I am confused with line 9, and i want to put a code in line 9 that can go inside through LocalPlayer's inventory and destroy the tool.. tool's name = tool

please tell me the answer scripting veterans..

1 answer

✓ Accepted answer

Its pretty simple, on line 9 write the following code

player.Backpack:FindFirstChild("tool"):Destroy()

or

tool:Destroy()

the FindFirstChild function basically finds the first child with the name provided.

3 comments

0

ur rlly smart! thx!

0

But, number 1 solution isn't working. XD Error says Players.(PlayerName).Backpack.Tool.LocalScript2:9: attempt to index a nil value

0

Did you put both of them together?

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