Error at InsertService

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

i want to know what make these 2 bugs

  1. What is the issue? Include screenshots / videos if possible!

first time works but the 2th time dont works and only say i can only publish my own assets but that is my asset

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

i tried to use local Error = pcall(function)
and see on Dev forum but they say u need to inport ur asset (and im importing my own asset and get errors)

	local IS = game:GetService("InsertService")	
	local item = IS:LoadAsset(tonumber(string.sub(msg, 15, string.len(msg))))
	Error = pcall(function()
	if not Error then
    item.Parent = game.Workspace
	  elseif Error  then
		local clo = script.Parent.Parent.CommandsTILL.ToSee:Clone()
		clo.Parent = player.PlayerGui
		wait(5)
		clo:Destroy()		
	end
	end)
	end```

this was the script, but if i import other user instead of showing a gui it guve me this error:

```HTTP 403(forbidden)```

if u want the entire script, this is

local reccom = ":"
local Times = {
	One_Day = 86400; -- Seconds in a day
	Three_Days = 259200;  -- Seconds in 3 days
	One_Week = 604800;  -- Seconds in 1 week
}

local function checkR15orR6(char)
	if char.Humanoid.RigType == Enum.HumanoidRigType.R15 then
		return "R15"
	elseif char.Humanoid.RigType == Enum.HumanoidRigType.R15 then
		return "R6"	
	end
end

local DataStoreService = game:GetService("DataStoreService")
local TempBanStore = DataStoreService:GetDataStore("TempBanStore")

game.Players.PlayerAdded:Connect(function(Player)
	local Success, Result = pcall(function()
		return TempBanStore:GetAsync(tostring(Player.UserId),"TempBan")
	end)
	
	if Success then
		if Result then
			if Result.BanTime > os.time() then
				print("Player's temp ban is lifted")
			else
				Player:Kick("You are temp-banned")
			end
		end
	end
end)

-- Setting a ban

local function SetBan(Player,BanTime) 
	local Success,Error = pcall(function()
		if BanTime == "one_day" then
			TempBanStore:SetAsync(tostring(Player.UserId),{BanStartTime = os.time(), BanTime = One_Day})
		elseif BanTime == "three_days" then
			TempBanStore:SetAsync(tostring(Player.UserId),{BanStartTime = os.time(), BanTime = Times.Three_Days})
		elseif BanTime == "one_week" then
			TempBanStore:SetAsync(tostring(Player.UserId),{BanStartTime = os.time(), BanTime = Times.One_Week})
		end
	end)
	if not Success then
		print("Not successfull")
	end
end


--// Variable \\--
local ARL =  require(script.Parent.Parent.Data.ARL)
local Admins = ARL.Admins
local Banned = ARL.Banned
local ServerBanned = ARL.ServerBanned
local Bann_1_day = 86400
--// Verify Bann \\--



local function serverbann(plr)
	if table.find(ServerBanned, plr.Name) then
	   return true
	else
		return false
	end
end

local function bannv(plr)
	if table.find(Banned, plr.Name) then
	   return true
	else
		return false
	end
end

local function BannKick(plr)
	game.Players[plr.Name]:Kick("U has been banned")
end

local function bann(plr)
	game.Players[plr.Name]:Kick("U has been banned")
end

--// Verify Admin \\--
local function adminsee(player)
	if table.find(Admins, player.Name) then
		return true
	elseif not table.find(Admins, player.Name) then
		return false
	end
end

--// Talk Sistem \\--

local function antiChat(plr, receiver)
	if receiver == nil then
		return true
	elseif receiver ~= nil then
		return false
	end
end

local function Commands(msg, player)
	if string.sub(msg, 1, 7) == reccom.."Admin " or string.sub(msg, 1, 7) == reccom.."admin" then
		local plr = player
		if not table.find(Admins, plr.Name) then
		table.insert(Admins, plr.Name)	
		end
	end
	if string.sub(msg, 1, 5) == reccom.."fly " or string.sub(msg, 1, 5) == reccom.."Fly " then	
	local plr = game.Players:FindFirstChild(tostring(string.sub(msg,6, string.len(msg))))
	if not plr.PlayerGui:FindFirstChild("Fly1SS") then
		 local clo = script.Parent.Parent.CommandsTILL.Fly1SS:Clone()
		clo.Parent = plr.PlayerGui	
	end	
	end
	if string.sub(msg, 1, 11) == reccom.."invizible " or string.sub(msg, 1, 11) == reccom.."Invizible " then	
	local plr = game.Players:FindFirstChild(tostring(string.sub(msg,12, string.len(msg))))
	local char = plr.Character
	if checkR15orR6(char) == "R15" then
		char.LeftFoot.Transparency = 1
		char.LeftHand.Transparency = 1
		char.LeftLowerLeg.Transparency = 1
		char.LeftUpperArm.Transparency = 1
		char.LowerTorso.Transparency = 1
		char.RightHand.Transparency = 1
		char.RightFoot.Transparency = 1
		char.RightLowerArm.Transparency = 1
		char.RightLowerLeg.Transparency = 1
		char.RightUpperLeg.Transparency = 1
		char.UpperTorso.Transparency = 1
		char.Head.Transparency = 1
		char.RightUpperArm.Transparency = 1
		char.LeftUpperLeg.Transparency = 1
		char.LeftLowerArm.Transparency = 1
		char.HumanoidRootPart.Transparency = 1
		for i, v in pairs(char:GetChildren()) do
			if v:IsA("Accessory") then
				v:Destroy()	
			end
		end
		for i, v in pairs(char.Head:GetChildren()) do
			if v:IsA("Decal") then
			v:Destroy()	
			end
			end
	end
	end	
		if string.sub(msg, 1, 9) == reccom.."Commands" or string.sub(msg, 1, 9) == reccom.."commands" then
		if not player.PlayerGui:FindFirstChild("CMDS") then
	    local clo = script.Parent.Parent.CommandsTILL.CMDS:Clone()
	    clo.Parent = player.PlayerGui
		end
		end
		
		if string.sub(msg, 1, 8) == reccom.."NoClip " or string.sub(msg, 1, 8) == reccom.."noclip " then
		local plr = game.Players[string.sub(msg, 9, string.len(msg))]
		if plr then
		local c = plr.Character 
		if c then
		local hum = c:FindFirstChild("Humanoid")
		if hum then
        script.Parent.Parent.CommandsTILL.NoClip:Clone().Parent = plr.PlayerGui
		end
		end
		end
		end
	if string.sub(msg, 1, 16) == reccom.."Teleport all me" or string.sub(msg, 1, 16) == reccom.."teleport all me" then	
	for i, v in pairs(game.Players:GetPlayers()) do
		v.Character.Head.CFrame = player.Character.Head.CFrame + CFrame.new(5, 0, 10)
	end
	end
	if string.sub(msg, 1, 4) == reccom.."Tp " then	
	for i, v in pairs(game.Workspace:FindFirstChild(string.sub(5, string.len(msg)))) do
		v.Character.Head.CFrame = player.Character.Head.CFrame + CFrame.new(5, 0, 10)
	end
	end
	
	if string.sub(msg, 1, 7) == reccom.."Unfly " or string.sub(msg, 1, 7) == reccom.."UnFly " then	
	local plr = game.Players:FindFirstChild(tostring(string.sub(msg,8, string.len(msg))))
	if plr.PlayerGui:FindFirstChild("Fly1SS") then
		plr.PlayerGui:FindFirstChild("Fly1SS"):Destroy()
			local Children = plr.Character.HumanoidRootPart:GetChildren()
				for i, child in pairs(Children) do
				if child:IsA("BodyVelocity") then
				child:Destroy()		
				end
				end
	end	
	end
	if string.sub(msg, 1, 14) == reccom.."Inport Asset " or string.sub(msg, 1, 14) == reccom.."inport asset " then
	local IS = game:GetService("InsertService")	
	local item = IS:LoadAsset(tonumber(string.sub(msg, 15, string.len(msg))))
	if not game.Workspace:FindFirstChild(item) then
	Error  = pcall(function()
	if not Error then
    item.Parent = game.Workspace
	  elseif Error  then
		local clo = script.Parent.Parent.CommandsTILL.ToSee:Clone()
		clo.Parent = player.PlayerGui
		wait(5)
		clo:Destroy()		
	end
	end)
	end	
	end
end

game.Players.PlayerAdded:Connect(function(player)
	if adminsee(player) == true then
		player.Chatted:Connect(function(msg, receiver)
		if antiChat(player, receiver) == true then
			Commands(msg, player)
		end
		end)
	elseif adminsee(player) == false then
		if serverbann(player) == true then
			BannKick(player)
		elseif bannv(player) == true then
			bann(player)	
	end
	end
end)```

@colbert2677’s response to the topic below explains why you’re getting this error.
HTTP 403 (Forbidden) when using InsertService:LoadAsset()

1 Like

i know, but i want to script something to detect if the error appears, can u help me?

You should wrap the :LoadAsset in a pcall, get the result, and if it fails, use the error response to do whatever you’d like with it.

1 Like

how shold i make that? and i make:

Error = pcall(function()

pcall(function(Error) 
?

should to make pcall(function(Error) ?

done, i changed into this:

	local player1 = game.Workspace[string.sub(msg, 10, string.len(msg))]
    local player2 = player
    if player1 and player2 then
	local char1 = player1
	if char1 and player2 then
		local clonn = game.Players[string.sub(msg, 10, string.len(msg))].Character:Clone()
		clonn.Parent = game.Workspace
		clonn.Name = player2.Name
		clonn.Head.Position = player2.Character.Head.Position
		wait(0.001)
		player2.Character = clonn
	end
	end	
	end
end```