Randomized Vector3 Values

cough cough yes I am a new developer, and the answer to this might be stupidly simple but…

so my question is, how would you generate a random vector3 position over an area of 5000 x 5000 stud?
for example let’s say I’d like to generate lighting bolts (evlighting) because I’m lazy to make my own,
but, how would I generate random vector3 positions?

4 Likes

local randVec = Vector3.new(math.random() * 5000, y, math.random() * 5000)

If you want to position it:
local randVec = Vector3.new(math.random() * 5000 + x, y, math.random() * 5000 + z)

If you want it to randomize from the center point:
local randVec = Vector3.new((math.random() * 5000) - 2500, y, (math.random() * 5000) - 2500)

If you want it to randomize from the center point but positioned:
local randVec = Vector3.new(((math.random() * 5000) - 2500) + x, y, ((math.random() * 5000) - 2500)+ z)

13 Likes

oh my god dude, I didnt know it was that simple! I really appreciate people like you!

2 Likes

Np and good luck!

1 Like