Ad
Log in to vote
1

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

Asked by 9 months ago

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

Log in to vote
1
Answered by
moo1210 587 Moderation Voter
9 months ago

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

0
Alright, I'll give that a try. deeskaalstickman649 388 — 9mo
0
A little dissapointing how i can't have the number as high as i wanted, but its fine. deeskaalstickman649 388 — 9mo
Ad
Log in to vote
1
Answered by
zadobyte 692 Moderation Voter
9 months ago
Edited 9 months ago

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
Can't blame you for trying. deeskaalstickman649 388 — 9mo
1
i just got an answer though zadobyte 692 — 9mo

Answer this question