InsertService not putting tool into game

I’m trying to make an admin system including a :gear command. It is almost complete but InsertService is not inserting the gear that I select when in the script, even though the exact same line works in the command bar in studio.

function commands.gear(plr, giveplr, id)
	if allowed(plr) >= tonumber(3) then
		local plrToGive = getPlayer(plr, giveplr)
		if plrToGive then
			if plrToGive == "all" then
				for i,v in ipairs(players:GetPlayers()) do
					local gear = IS:LoadAsset(id)
					gear.Parent = plr.Backpack
				end
			elseif plrToGive == "others" then
				for i,v in ipairs(players:GetPlayers()) do
					if v ~= plr then
						local gear = IS:LoadAsset(id).Parent = workspace
						gear.Parent = plr.Backpack
					end
				end
			else
				local gear = IS:LoadAsset(id)
				print(gear.Parent)
				gear.Parent = plr.Backpack
				print(gear.Parent)
			end
		end
	end
end

Is there a solution to fixing this problem?

InsertService only works if you own the asset or if it’s a official Roblox item. What are you trying to load? Also this can help: InsertService:LoadAsset

Firstly

Why is there a parent assignment here, shouldn’t that cause an error?

My only idea as to why it isn’t working is that it’s either not going into the LoadAsset part, or something is wrong with the ID itself, which is the more likely issue. How are you passing in the id? May we see the section of code where you call commands.gear

Pretty much the goal is anything from this catalog section:

No, you can add parent to end of an instance object, there is no error there.

Thing is they were doing it whilst trying assign it to a variable, if it was just IS:LoadAsset(id).Parent = workspace it would work, but they’re assigning it to a gear variable

Hmm, yea you can’t set the parent from variable. I misunderstood you. There is an issue there.

1 Like
if string.find(message, prefix) then
			local starts, ends = string.find(message, prefix)
			
			local mwp = string.sub(message, ends + 1, #message)
			local args = string.split(mwp, " ")
			local command = args[1]
			
			if commands[command] then
				table.remove(args, 1)
				commands[command](player, table.unpack(args))
			end
			
		end

The message that is sent is split here and sent.

I think your issue is that the ID is still a string since I don’t see any tonumber there, try converting id to a number before any of the LoadAsset in your commands.gear