Randomly Spawning Objects Above the Map?

So I am Currently working on a game of mine and I am not scripter but I am trying to do most the project myself. And such I am Completely stumped on this I have no Idea How to spawn actual objects. And I haven’t been able to find any Good Videos or such on the topic. Any Help is Welcome.

3 Likes

Like clone an object and spawn it randomly above the map. Like falling rocks?

local clone = game.ServerStorage:WaitForChild("Rock")

while wait() do
       local position = Vector3.new(math.random(1,100),25,math.random(1,100))
       local clonedobject = clone:Clone()
       clonedobject.Position = position
       clonedobject.Parent = game.Workspace
end
2 Likes

You can move stuff from ServerStorage to Workspace every now and again if you want

Yes. Almost exactly like that although I have my own function for the objects.

So have a repeating script that moves the object into the Workspace?

What are you trying to find, are you trying to make random objects fall above the map?

1 Like

You can use math.random to place them in a random position. Is the object a model or a part? If its a model you need to use model:SetPrimaryPart position.

1 Like

Yes. That is Correct. “This Needs to be longer”

Thank you Ill try that. Be back in a bit.

Do you want a random type of object? Like it spawns a chair at first then it might spawn a table etc… You could put them all in a folder and clone a random object out of the folder.

1 Like

There’s a tutorial here Beginner’s Roblox Scripting Tutorial #16 - Random (Beginner to Pro 2019) [FIXED] - YouTube

1 Like

I was wanting a specific object. But thank you anyway.

And what’s that specific object?

May I ask how should I make them spawn in interviles?

As in how to spawn them in a large area or what

1 Like

Yes spawn them in around the size of a baseplate in the sky. one every second but thats easy to change.

Try something like this:

local part = game.Workspace.Part -- change this with whatever is your target

while wait(math.random(1,10) do
    local clone = part:Clone
    clone.Position = Vector3.new(math.random(1,100), 100, math.random(1,100))
end

I don’t think that it will work but you should somehow try to get the clone to spawn somewhere random.

it depends on where your baseplate is and where you want to spawn them
x-axis = left and right
y axis = up and down
z-axis = front and back
record the x-axis and z-axis and write like this

while true do
wait(1)
local xPosition = math.random() -- fill in the x-axis
 local zPosition = math.random() -- fill in the z-axis
-- after that just make them all together
part.Position = Vector3.new((xPosition,100,zPosition)
end

This won’t work because you need a Vector3 for the position value and for math.random you can only place 2 values.

i know im editing u gotta chill mate