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

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

Asked by 8 years ago

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

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

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.

0
ur rlly smart! thx! Scripter_Blan 25 — 8y
0
But, number 1 solution isn't working. XD Error says Players.(PlayerName).Backpack.Tool.LocalScript2:9: attempt to index a nil value Scripter_Blan 25 — 8y
0
Did you put both of them together? connor12260311 383 — 8y
Ad

Answer this question