Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make a model randomly spawn from several dropper locations?

Hello hello, I'm pretty new to scripting and most of my limited knowledge comes from editing premade scripts, but I can't figure out how to clone this model (Model1) into Workspace randomly to one of the positions of a choice of droppers:

local Storage = game.Lighting
local model = Storage.Model1
local Dropper = game.Workspace("1","2","3")

while true do
	wait(math.random(1,10))
    local DropClone = model:Clone()
    DropClone.Parent = game.Workspace
    DropClone:MoveTo(game.Workspace.Dropper.Position)
end

This code is obviously very wrong lol, but I'm trying to get DropClone to move randomly to one the locations named "1", "2", or "3"

any help appreciated! much thanks <3

1 answer

✓ Accepted answer
local Storage = game.Lighting
local model = Storage.Model1
local Droppers = {game.Workspace["1"], game.Workspace["2"], game.Workspace["3"]} -- Organize droppers into table for later

while true do
    wait(math.random(1,10))
    local DropClone = model:Clone()
    DropClone.Parent = game.Workspace

    local Dropper = Droppers[math.random(#Droppers)] -- Choose random dropper
    DropClone:MoveTo(Dropper.Position) -- Move to dropper position
end

Also, I recommend you grouping all of your droppers together in a model named Droppers and replacing line 3 with this so you can add Droppers without updating the table:

local Droppers = workspace:WaitForChild("Droppers"):GetChildren()

EDIT: One more thing, I would not put models inside of Lighting. Instead, put them in ServerStorage. Storage in Lighting is a thing of the past!

If this helped, upvote/mark correct! Thank you! If you ever want quick help from me, add me on Discord at doggo#0001. I'm usually able to respond quickly

This discussion is preserved as it was. New answers, comments, and votes are closed.