Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make this RANDOM model inserter only find models from the Library?

Asked by 4 years ago
Edited 4 years ago

I'm having a problem trying to make this chaotic game where it inserts a random model from the Library every 3 seconds. Then, at a random interval, it removes that random model. But never wants to find model assets. All it finds are other assets. How do I make it so it only finds models?

01local InsertService = game:GetService("InsertService")
02while wait(3) do
03    local success, response = pcall(function()
04        local min = 1
05        local max = 9999999999
06        local modelID = math.floor(math.random() * (max - min) + min)
07        local model = InsertService:LoadAsset(modelID)
08        model.Parent = workspace
09        wait(math.random(1,100))
10        model:Destroy()
11    end)
12end

1 answer

Log in to vote
1
Answered by 4 years ago

The solution is to check if the model:IsA("Model") and if it's the case, add it in workspace.

I went ahead and organized your script. What it does is generate a new model every 3 seconds. It checks if the model exists and if it does parents it in workspace. Then it runs a coroutine to destroy the model after a random amount of time while it can continue generating new models every 3 seconds.

Here's what it looks like:

01local InsertService = game:GetService("InsertService")
02 
03local function ModelExists(modelID)
04    local model
05    local success, fail = pcall(function()
06        local model = InsertService:LoadAsset(modelID)
07    end)
08    if success then
09        print("Is an existing model")
10        return true
11    end
12end
13 
14local function DestroyItem(whichItem)
15    wait(math.random(1,100))
View all 38 lines...

Let me know if that answers your question!

0
I sorta abandoned this quickly because I realesed InsertService has this really bad limitation where it can only insert models made by Roblox and the creator. So yeah. squidiskool 208 — 4y
Ad

Answer this question