InsertService not loading an asset in (Bad request)

I have this function I’m using to handle the case of Roblox failing to insert the model, since it’s very integral to the game. To handle it, it makes another request to load the asset after x amount of seconds if it failed to before.

The place this is being run in is a group place and the model is free.
The code works in test servers and in ‘Play Mode’, but doesn’t work in an actual server.

So far I’ve played around with no pcall (just throws an error on the LoadAsset line and with no message for what the error is except for giving the stack), and I’ve looked at half a dozen other questions related to LoadAsset as well as the wiki and none of these really help.

Code Output

Code

01	local function loadAssetUntilWorks(id, maxTries)
02	    local model,success,message
03	    local i = 0
04	 
05	    --Sets the maxTries to -1 (making the loop infinite) if maxtries isn't
06	    --specified or is less than 0
07	    if not maxTries then
08	        maxTries = -1
09	    elseif maxTries < 0 then
10	        maxTries = -1
11	    end
12	 
13	    print("Settings - maxTries: " .. maxTries)
14	 
15	    --Makes sure the amount of tries isn't 0
16	    if maxTries ~= 0 then
17	        repeat
18	            print("Settings - On try numbah " .. i)
19	            --Keeps trying until successful and then returns the model 
20	             
21	            success,message = pcall(function()
22	                model = InsertService:LoadAsset(id) --The problem line
23	            end)
24	            if success then
25	                return model
26	            else
27	                i = i+1
28	                warn("Whoopsie: " .. message)
29	                wait(WAIT_TIME_BEFORE_SECOND_ATTEMPT)
30	            end
31	        until i==maxTries
32	    else
33	        return
34	    end
35	end
2 Likes

Try without pcall see if it has an error id, for example Bad request 404.

Do you or Roblox have ownership of the asset?

Are you requesting too often? The limit is 100 times per 1 minute so do wait(.6) it will fix the issue.

1 Like

When I don’t use a pcall it throws an error without a message at all, it only shows the stack

I own it, the asset is free, and it’s being inserted on a group-owned game.

WAIT_TIME_BEFORE_SECOND_ATTEMPT is set to 2, so it only makes another request every two seconds

Could you give us an example of the id you’re struggling with? It could be that you do not have access to the asset.

2715063294

It’s a model I made that’s free. I’m trying to insert it in a group place.
It works fine in Play mode and in a test server but doesn’t work in an actual server.

Alright, this certainly is weird. I attempted to insert several of your free models into my studio, I received “HTTP Error 403” - which basically is forbidden. I did this several times and I always got Error 403, then I took one took one of your models (clicked “Get”) - then when I tried with the model I just took, I received a Bad Request instead.

And I even tried again with models that I had not taken, and it gave me Bad request, where it just before I took the model had given me 403 errors.

EDIT: Okay, this must be a bug. Here’s what happened:

Model: FreeCamCode - Roblox

  • I opened Roblox Studio, and launched a command to get this model, I was met with 403 errors. I attempted to use InsertService multiple times
  • I went back to the browser and took the model (clicking “Get” etc.) - when I went back to studio to try to load it in again, I got a “Bad Request”.
  • I opened a new studio, and while having the model, I attempted to load it in again, I was met with 403 errors again
  • I closed the last Studio window, and opened a new one, now when I tried to use InsertService to load it in, it magically worked.

NEW EDIT: It appears to be due to caching. If you attempt to insert the model without taking it first, it won’t work. If you first tried without taking it, then it won’t work until you re-open studio. I haven’t dug into anything else.

Edit again:

Even with the model taken

2 Likes