0

# why this is NextInteger Returning nill ?

Can someone help me out? a Random.NextInteger function is returning nill everytime i run it

the function returning the nill

local Tables = GetTablesFromAttackAnimation1(AttackFrameModule, (CanBackstab and AttackFrameModule.BackstabAnimation) and "BackstabAnimationTable" or RealType, AttackNumber)
local Table = Tables[Random.new():NextInteger(1, #Tables)]
print(Table)
LastComboDelay = Table[3][2]


the function itself

local function GetTablesFromAttackAnimation1(AttackFrameModule, AttackType, Attack)
local Tables = {}
print(Attack)
for _, v in pairs(AttackFrameModule[AttackType]) do
if v.AttackType == Attack then
print("oi2")
table.insert(Tables, {v.Id, v.Speed,
{v.AttackDelay, v.ComboDelay, v.HitboxTimes, v.RaycastHitboxInstances},
{v.Hitbox.HitboxType, v.Hitbox.HitboxShape, v.Hitbox.HitboxSize, v.Hitbox.HitboxCFrame, v.Hitbox.MaxPartsInRegion}})
end
end

return Tables
end


the table

{
Id = "rbxassetid://9518474867", Speed = 1, AttackDelay = 0.6, ComboDelay = 0.6, HitboxTimes = {0, 0.5}, RaycastHitboxInstances = {{"Tool", "Handle"}}, DashDelay = 0, DashVelocity = 1, DashLifeTime = 2, AttackType = "1",

Hitbox = {
HitboxType = "RaycastHitbox",
--RotatedRegion
HitboxShape = Enum.PartType.Block,
HitboxSize = Vector3.new(4, 4, 7),
HitboxCFrame = CFrame.new(0, 1, -2),
MaxPartsInRegion = 50,
}
},


0
Hello :D, I got to say you got very interesting way of passing arguments, and maybe this is the source of problem, I am not sure at all how and works in passing arguments. When you have or it takes the first parameter, and if its true it continues without checking second one, there is example:
local humanoid = player.Character:FindFirstChild("Humanoid") or player.Character:WaitForChild("Humanoid")

If humanoid is not present first will return nil which means it will do the second one, wait for it. I dont know about and character uses at all. Change this parameters, try to erase all and and make sure you use or only for purpose I just showed you. I am sorry I cannot rewrite the code my self, because I dont understand what you want to really pass. I hope this will help you fix the problem, good luck, and I hope you will have nice rest of day.