Spread script causing an "Unable to cast double to token" error

It was hard to learn how to rotate blocks, whatever, i have a script that rotates some blocks to a random direction, causing a bullets spread effect:

local Sh = math.random(0,20)
local Sh1 = math.random(0,20)
r.Orientation = Vector3.FromAxis(Sh,Sh1,0)

Well, the last line is causing an error, which i have noticed for the first time: Unable to cast double to token, i tried to search in the developer hub or in the forum for some helpful results, but they were not useful. Well, trying to rotate blocks in scripts is something new for me, i thought i would get this kind of errors, thanks for reading.

1 Like

Use Vector3.new() for setting a part’s orientation. Vector3.FromAxis() uses an enum to construct a Vector3 on one axis (I think?).

1 Like

Yep, you are correct. FromAxis takes an Axis Enum and this could’ve further been confirmed by reading the Vector3 page. This is why it’s imperative to research before posting threads: this question could’ve been answered by spending a few seconds going to the Developer Hub and confirming that the Vector3 API was being used properly in this scenario.