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

Attempt to index nil with backpack!??

Asked by 2 years ago
script.Parent.MouseButton1Click:Connect(function()
    local name = script.Parent.Parent.plrname.ContentText
    local player = game.Players.LocalPlayer
    local plr = game.Players:FindFirstChild(name)
        for i,v in pairs(player.BackPack) do
        v:Clone().Parent = plr.BackPack
        wait(.2)
        v:Destroy()
    if game.ReplicatedStorage.orders.order.Value == 1 then
                game.ReplicatedStorage.orders.order.Value = game.ReplicatedStorage.orders.order.Value -1
           end
        end
    end)

This is meant to take the text from the textbox and use that to find the name of the player. Then, it will give that player all of the items in the player that clicked the gui has. Please Help!

0
"BackPack" should be written as "Backpack", "pairs(player.BackPack)" should be written as "pairs(player.Backpack:GetChildren())" since you need to iterate over the children imKirda 4491 — 2y
0
your error says that "plr" is nil, that means it does not exist, replace "plr.BackPack" with "player.Backpack", your "plr" variable is useless imKirda 4491 — 2y
0
Still doesnt work. i just get the error "Players.Mrpolarbear2games.PlayerGui.Employer.Frame.send.Script:5: attempt to index nil with 'Backpack'"? Mrpolarbear2games 55 — 2y
0
plr isnt the "sender" plr is the plr that you are giving the item to. Mrpolarbear2games 55 — 2y
0
"FindFirstChild" requires string as first parameter, in your case it's the text label, try "game.Players:FindFirstChild(name.Text)", this however does not help well since you are giving the player tools on client, you should do that on server otherwise only you are going to see the change, see RemoteEvents imKirda 4491 — 2y

Answer this question