I'm getting an error stating attempt to index nil with Backpack?
Asked by
3 years ago Edited 3 years ago
This is a script located in serverscriptservice. All it does is once the gui called "Employer" has been clicked to send items it fires a remote event that will then clone the items from the person using the "Employer" Gui and give them to the person whose name has been written in plrname (plrname is a textbox). Please help! Thanks in advance!
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | game.ReplicatedStorage.fyg.OnServerEvent:Connect( function () |
03 | for i,v in pairs (game.Players:GetChildren()) do |
04 | local fu = v:FindFirstChild( "PlayerGui" ) |
05 | local fa = fu:FindFirstChild( "Employer" ) |
06 | local fe = fa:FindFirstChild( "Frame" ) |
07 | local fo = fe:FindFirstChild( "plrname" ) |
08 | local plr = game.Players:FindFirstChild(fo.Text) |
09 | local pack = plr.Backpack |
10 | for i,v in pairs (player.Backpack:GetChildren()) do |
11 | v:Clone().Parent = pack |
EDIT: the script to fire the remote event contains:
1 | script.Parent.MouseButton 1 Click:Connect( function () |
2 | local event 1 = game.ReplicatedStorage.fyg |
4 | if game.ReplicatedStorage.orders.order.Value = = 1 then |
5 | game.ReplicatedStorage.orders.order.Value = game.ReplicatedStorage.orders.order.Value - 1 |