Workspace.MilitaryItemSpawner.Spawn:49: bad argument #2 to 'random' (interval is empty)

I’m having this issue when ever I call math.random. I input two numbers and I get this error. For some reason it still prints the numbers though?

		local CPX1POS, CPX2POS, CPX3POS = CornerPartX1.Position.X, CornerPartX2.Position.X, CornerPartX3.Position.Z
		local FX, FX2, FZ = string.split(tostring(CPX1POS), "."), string.split(tostring(CPX2POS), "."), string.split(tostring(CPX3POS), ".")
		local FX, FX2, FZ = FX[1], FX2[1], FZ[1]
		local FX, FX2, FZ = tonumber(FX), tonumber(FX2), tonumber(FZ)
		print(FX..", "..FX2)
		local X = math.random(FX, FX2)
		local Z = math.random(FX, FZ)

Printed Numbers:
image

This error appears when the #2 argument is smaller than the first argument.

1 Like