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.
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