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

Math.Random for vector3 positions, How to use?

Asked by
hokyboy 270 Moderation Voter
3 years ago
01--[[
02Settings for terrian generation
03]]
04 
05local Maxheight = 10
06local Minheight = -10
07 
08--[[
09Varibles
10]]
11 
12local GenerationInProgress = false
13local TerrianGenerationFinished = false
14local IsChunkLoading = false
15 
View all 56 lines...

My error is ServerScriptService.Script:51: invalid argument #2 to 'random' (interval is empty) witch is in the nodeloop function

0
hey math.random(minheight,maxheight) not math.random(maxheight,minheight) Remember thank, goodbye. lehoaiquoc248 23 — 3y

2 answers

Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

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.

Here are the fixed script(s):

01--[[
02Settings for terrain generation
03]]
04 
05local Maxheight = math.random(10)
06local Minheight =math.random(-10)
07 
08 
09--[[
10Variables
11]]
12 
13local GenerationInProgress = false
14local TerrianGenerationFinished = false
15local IsChunkLoading = false
View all 57 lines...

OR you could do this:

01--[[
02Settings for terrain generation
03]]
04 
05 
06--[[
07Variables
08]]
09 
10local GenerationInProgress = false
11local TerrianGenerationFinished = false
12local IsChunkLoading = false
13 
14local TerrianFolder = workspace.TerrianF
15local Chunks = TerrianFolder.Chunks
View all 54 lines...

Edit: Fixed grammatical errors!

Ad
Log in to vote
0
Answered by 3 years ago

going off the principal that Vector3.new has the parameters in order of Vector3.new(X,Y,Z), we can use this:

1Vector3.new(0,math.random(minheight,maxheight),0)

to create a new random vector between minheight and maxheight on the Y axis (up/down).

Answer this question