I'm trying to insert an accessory onto the player using LoadAsset and get the hat ID via a textbox but whenever I try to insert the hat it gives me this error: attempt to index nil with 'Parent'. I don't know what is nil. If I change FindFirstChild(plr) in the server script to FindFirstChild(JCAspit) it works. The local script is in the textbox and the server script is in ReplicatedStorage. I can insert gears as well and it works fine but it still gives me the error after it inserts.
Local Script
local assetID = script.Parent
backpack = game.Players.LocalPlayer.Backpack
plr = game.Players.LocalPlayer.Name
script.Parent.FocusLost:connect(
function(enterPressed)
if enterPressed then
-- print(assetID.Text.. " ID was set")
game.ReplicatedStorage.RemoteFunction:InvokeServer(assetID.Text, backpack, plr)
-- print(assetID.Text.. " after invoke")
end
end)
Server Script
game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player, assetID, backpack, plr)
print(assetID)
print(plr)
if plr then
game:GetService("InsertService"):LoadAsset(assetID):FindFirstChildWhichIsA("Tool").Parent=backpack
print("Tool inserted")
game:GetService("InsertService"):LoadAsset(assetID):FindFirstChildWhichIsA("Accessory").Parent=workspace:FindFirstChild(plr)
print("Accessory inserted")
end
end

2 comments
What line errors? Plus, "nil" is the lua term for "nothing", which means when you say "thing.Parent", the object parented to it is "nil".
When I click the error it sends me to the 9th line in the Local Script, I can't figure out what is nil or nothing.