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

How would I go about randomizing points on a single axis?

Asked by 8 years ago

I'll get right to it, then: I have a grid of points, all of the points are 1x1x1 blocks that are anchored, and each is five studs from the next on both the X and Z axes. I want each point to go up or down based on a random number for each, so all of the points are at a random height. However, when I run my script, all of the numbers are the same, resulting in identical Y axis position for all of the parts. My current script is as follows, and is the same in every part on the grid:

math.randomseed(tick())

for  i = 1, 10 do
    variation = (math.random()*10)/20
end

local part = script.Parent

part.Position = Vector3.new (part.Position.X, variation, part.Position.Z)
print(variation)

My question is this: How would I change my current script/create a new one so that all of the points are randomized?

Answer this question