i was making generation terrain with cubes like, when cube is too high, it should be mountain but if cube is too low, it should be grass but Math is not working
Ignore others scripts,
local cube = script.Parent
local x = 0
local y = -1
for i = 1,100 do
local terrain = cube:Clone()
task.wait()
x += 1
if math.random(1,2) == 1 then
y += math.random(-1,1)
end
-- Target --
if terrain.Position.Z <= 15 then
print("grey")
print(y)
terrain.Material = Enum.Material.Slate
terrain.BrickColor = BrickColor.new("Grey")
else
terrain.Material = Enum.Material.Grass
print(y)
print("grass")
terrain.BrickColor = BrickColor.new("Dark green")
end
-- Target --
terrain.Position = Vector3.new(-x,y,terrain.Position.Z)
terrain.Script:Destroy()
terrain.Parent = workspace
end
How i do fix it??
when i tried Simple if then. the result is right answer but this script? no
2 posts - 1 participant