--[[ Settings for terrian generation ]] local Maxheight = 10 local Minheight = -10 --[[ Varibles ]] local GenerationInProgress = false local TerrianGenerationFinished = false local IsChunkLoading = false local TerrianFolder = workspace.TerrianF local Chunks = TerrianFolder.Chunks function StartGeneration() if GenerationInProgress == false and TerrianGenerationFinished == false then GenerationInProgress = true LoadChunk() warn("Started Loading Chunk") else warn("Error Code 0/01") end end function LoadChunk() if IsChunkLoading == false then ChunkLoop() else warn("Error Code 0/02") end end function ChunkLoop() for i,v in pairs(Chunks:GetChildren()) do if v.IsLoaded.Value == false then IsChunkLoading = true NodeLoop(v) else warn("Error 0/03") end end end function NodeLoop(v) for i,n in pairs(v.Nodes:GetChildren()) do n.Position = Vector3.new(0,math.random(Maxheight,Minheight),0) warn("Set Nodes i guess?") end end StartGeneration()
My error is ServerScriptService.Script:51: invalid argument #2 to 'random' (interval is empty) witch is in the nodeloop function
Remember that Vector3 only takes 3 arguments, no more, of X, Y, Z. One of the intervals you added was empty, which were the ones outside the enclosed brackets.
--[[ Settings for terrain generation ]] local Maxheight = math.random(10) local Minheight =math.random(-10) --[[ Variables ]] local GenerationInProgress = false local TerrianGenerationFinished = false local IsChunkLoading = false local TerrianFolder = workspace.TerrianF local Chunks = TerrianFolder.Chunks function StartGeneration() if GenerationInProgress == false and TerrianGenerationFinished == false then GenerationInProgress = true LoadChunk() warn("Started Loading Chunk") else warn("Error Code 0/01") end end function LoadChunk() if IsChunkLoading == false then ChunkLoop() else warn("Error Code 0/02") end end function ChunkLoop() for i,v in pairs(Chunks:GetChildren()) do if v.IsLoaded.Value == false then IsChunkLoading = true NodeLoop(v) else warn("Error 0/03") end end end function NodeLoop(v) for i,n in pairs(v.Nodes:GetChildren()) do n.Position = Vector3.new(math.random(Maxheight,Minheight)) warn("Set Nodes i guess?") end end StartGeneration()
OR you could do this:
--[[ Settings for terrain generation ]] --[[ Variables ]] local GenerationInProgress = false local TerrianGenerationFinished = false local IsChunkLoading = false local TerrianFolder = workspace.TerrianF local Chunks = TerrianFolder.Chunks function StartGeneration() if GenerationInProgress == false and TerrianGenerationFinished == false then GenerationInProgress = true LoadChunk() warn("Started Loading Chunk") else warn("Error Code 0/01") end end function LoadChunk() if IsChunkLoading == false then ChunkLoop() else warn("Error Code 0/02") end end function ChunkLoop() for i,v in pairs(Chunks:GetChildren()) do if v.IsLoaded.Value == false then IsChunkLoading = true NodeLoop(v) else warn("Error 0/03") end end end function NodeLoop(v) for i,n in pairs(v.Nodes:GetChildren()) do n.Position = Vector3.new(math.random(10,-10))-- your positions warn("Set Nodes i guess?") end end StartGeneration()
going off the principal that Vector3.new
has the parameters in order of Vector3.new(X,Y,Z)
, we can use this:
Vector3.new(0,math.random(minheight,maxheight),0)
to create a new random vector between minheight
and maxheight
on the Y axis (up/down).