Right now it’s just using math.random() to place these trees. Is there a better way to space these trees out randomly so they’re more evenly scattered?
local function Place(Tree,i)
local PreviousPosition = Vector3.new(-233.008, 93.614, -155.379)
while i > 0 do
while true do
local Clone = Tree:Clone()
local Start = Vector3.new(math.random(-1050,865),400,math.random(-636,738))
local Direction = Vector3.new(0,-500,0)
local Raycast = workspace:Raycast(Start,Direction)
print(Raycast)
if Raycast then
if Raycast.Instance:IsA("Terrain") and Raycast.Material == Enum.Material.Grass and (Raycast.Position-PreviousPosition).Magnitude > 30 then
Clone.Parent = workspace.WorkspaceTrees
Clone:PivotTo(CFrame.new(Raycast.Position))
PreviousPosition = Raycast.Position
break
end
end
wait()
end
i-=1
end
end