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

How do I make random model spawn?

Asked by 6 years ago

I have a model, lumber tycoon 2 type thing and I need help coding how to spawn it randomly on a union called 'land' any help?

local land = game.Workspace.Land
local tree1 = game.ReplicatedStorage.TEST

function randomspawn()
    if 1 == 1 then

    end
end

this is all I have I have NO idea how to do it.

0
what's with the condition lol User#19524 175 — 6y
0
honestly no clue lol iRoklas 1 — 6y

1 answer

Log in to vote
0
Answered by
vkax 85
6 years ago
Edited 6 years ago

So, first things first.

You need to first get the position of the Part called "Land" and then use that for it randomly spawning, here would be an example for it:

local land = workspace:WaitForChild"Land"
local tree1 = game.ReplicatedStorage.TEST

randomspawn = function()
    local pos1 = math.random(5,FIRST PARAMETER OF LAND POSITION)
    local pos2 = math.random(5,THIRD PARAMETER OF LAND POSITION)
    local tree = tree1:Clone()
    tree.Parent = land
    tree.Position = Vector3.new(pos1,land height or however much you want it to spawn above,pos2)
end

That's an example for how to do it.

Don't you dare not accept this answer if it's not helpful

Ad

Answer this question