✓ Accepted answer
Looks like your running in to your X value going negative math.random() doesn't like negative values.
So I would Flip the X Value to positive then pass the new value to the math.random() function then times the value by-1 if it was negative
For example in code:
(Old answer Code)[INT]
local InaccuracyPossibility = Vector3.new(-5,1,2)
for i=1, 10 do
local bisXNeg = InaccuracyPossibility.X <= 0
local XAbs = math.abs(InaccuracyPossibility.X)
local XRandom = math.random((0 - XAbs), XAbs ) * (bisXNeg == true and -1 or 1)
print(XRandom)
end
Output:
2
-3
-1
-0
2
-1
-0
4
-1
3
(New Answer Code)[NUMBER(FLOAT)]
local InaccuracyPossibility = Vector3.new(-5.02,1.2,2.5)
for i=1, 10 do
local bisXNeg = InaccuracyPossibility.X <= 0
local XAbs = math.abs(InaccuracyPossibility.X)
local XRandom = (math.random()*XAbs) * (bisXNeg == true and -1 or 1)
print(XRandom)
end
Output:
-2.5070609002733
-0.61484114847888
-1.7726778006567
-1.0249097790085
-0.40516958552847
-2.1358409614483
-3.7283219967974
-4.8174073688361
-1.6732552332573
-4.0884841332942
i havent tested it in Roblox but it's working in notepad++ with a lua plugin!
(im on my phone lolz) :P
hope this helps!
2 comments
It worked fine for me.
Post all of your code here so I know what to do.