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 3 years ago
01script.Parent.MouseButton1Click:Connect(function()
02    local name = script.Parent.Parent.plrname.ContentText
03    local player = game.Players.LocalPlayer
04    local plr = game.Players:FindFirstChild(name)
05        for i,v in pairs(player.BackPack) do
06        v:Clone().Parent = plr.BackPack
07        wait(.2)
08        v:Destroy()
09    if game.ReplicatedStorage.orders.order.Value == 1 then
10                game.ReplicatedStorage.orders.order.Value = game.ReplicatedStorage.orders.order.Value -1
11           end
12        end
13    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 — 3y
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 — 3y
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 — 3y
0
plr isnt the "sender" plr is the plr that you are giving the item to. Mrpolarbear2games 55 — 3y
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 — 3y

Answer this question