Random.new():NextInteger Returning The Word "Random"

Code:

		local Spread = Random.new():NextInteger(-Values.Spread.Value,Values.Spread.Value)

Spread value:
image

Error:
image

Put full code, and use a print statement and see what the spread is actually.

I did use a print to print the spread, and it literally prints “Random”.

The code is for a raycast:

local Spread = Random.new():NextInteger(-Values.Spread.Value,Values.Spread.Value)
		local Raycast = workspace:Raycast(FirePos.Position,(MouseHitPos-FirePos.Position)+Spread*1.2,Params)

You can’t add numbers to a Vector3. Add a Vector3 to a Vector3 instead.

Code:

local Spread = Random.new():NextInteger(-Values.Spread.Value, Values.Spread.Value)
local Raycast = workspace:Raycast(FirePos.Position, (MouseHitPos - FirePos.Position) + (Vector3.one * Spread * 1.2), Params)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.