Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Invalid argument #2 to random, interval is empty, but it's not?

I understand the error, it's saying the 2nd argument is smaller than the 1st. However, the first argument has 8 digits whilst the 2nd argument has 11 digits. Here is the math.random()

local torque = Vector3.new(math.random(30000000, 12500000000), math.random(30000000, 12500000000), math.random(30000000, 12500000000))

, and here is the whole if statement including the FindPlayers().

local allPlayers = {}
local function FindPlayers()
	for i, playerSelected in pairs(game.Players:GetPlayers()) do
		table.insert(allPlayers, playerSelected.Character)
	end
end

if split[2] == 'greateryaYEET' then
	local torque = Vector3.new(math.random(30000000, 12500000000), math.random(30000000, 12500000000), math.random(30000000, 12500000000))
	local AV = Vector3.new(math.random(0, 720), math.random(0, 720), math.random(0, 720))
	local BAV
				
	if split[3] == 'me' then
		allPlayers = {player.Character}
	elseif split[3] == 'all' then
		FindPlayers()
	else
		allPlayers = {workspace:FindFirstChild(split[3])}
	end
				
	local success, eMes = pcall(function()
		for i, char in pairs(allPlayers) do
			char.Humanoid.Sit = true
			
			BAV = Instance.new('BodyAngularVelocity', char.HumanoidRootPart)
						
			BAV.MaxTorque = torque
			BAV.P = 2500
			BAV.AngularVelocity = AV
		end
	end)
	if success then
		print('Admin command successfully initiated!')
		wait(.5)
		BAV:Destroy()
		torque = Vector3.new(math.random(30000000, 12500000000), math.random(30000000, 12500000000), math.random(30000000, 12500000000))
		AV = Vector3.new(math.random(0, 720), math.random(0, 720), math.random(0, 720))
	else
		return eMes
	end
end

This could be an integer overflow? Note: The whole script is quite long, so i decided not to include it.

2 answers

✓ Accepted answer

Yep, are you are getting an integer overflow. There is not much you can do about this other than to remove an 0.

2 comments

0

Alright, I'll give that a try.

0

A little dissapointing how i can't have the number as high as i wanted, but its fine.

If the max of math.random is lower than the min (e.g. math.random(10,1)) it'll give that error.

Edit: My bad, didn't read the beginning of the post.

Edit 2: For some reason, it works when you remove one zero off the second number. As to why, I have no clue

2 comments

2

Can't blame you for trying.

1

i just got an answer though

This discussion is preserved as it was. New answers, comments, and votes are closed.