Return coming back as nil even though when printed on the Module the values exist

Saw a lot of other issues similar to this, but none of them between module and module on server-side.

Basically I have a hitbox system in place were it stores the hit characters in a table, and returns them if Hit is recognized.

Now, with the commented print, there was an actual result and table being returned. The issue becomes the fact that the table, is never recognized in the other modules where it’s called.

The HitResult and EnemyChar are always nil, no matter the circumstance, so I’m just confused as to why this issue occurs.

    if Hitbox.Linger and (tick() - Hitbox.DespawnTime) < Hitbox.Linger then
                    if Hit then
                        --print(Hit)
                        Hitbox.Activity = false
                        Hitbox.HitboxInfo[HitboxPIT] = nil
                        return true, Hit
                    end
                    
                    Hitbox.InUse = false
                    table.clear(Hitbox.Hit)

Where the value’s first get returned

local hitboxobj = HitM.New({Size = Vector3.new(3.5, 4.25, 4),
        Position = Player.Character.HumanoidRootPart,
        Attacker = Player.Character,
        InUse = true,
        Despawn = true,
        DespawnTime = tick(),
        Activity = true,
        MultiHit = false,
        CharacterCount = 5,
        AttackDebounce = 0.3,

        Linger = 1.2,
        Hit = {},})
        local HitResult, EnemyChar = hitboxobj:StartHitbox()
    
        print(HitResult, EnemyChar)
        
        return HitResult, EnemyChar

Where the values are meant to be referenced but instead say nil

These are both Modules. If you need further information, I’m willing to do so.

Just bumping since I woke up and I want to fix this as soon as possible.

in my knowledge, module scripts must return one value. try sending a table with the two vars then use table.unpack() in the receiving scripts

Unfortunately, when I send them as a table, the issue still seems to remain.

image
image
image

local temp = {HitResult, EnemyChar}
return temp

--receiving
local hitresult, enemychar = table.unpack(HandToHandHitbox(player))

its kinda hard to show you without the receiving script

1 Like

image

local Properties = {Size = Vector3.new(3.5, 4.25, 4),
		Position = Player.Character.HumanoidRootPart,
		Attacker = Player.Character,
		InUse = true,
		Despawn = true,
		DespawnTime = os.clock(),
		Activity = true,
		MultiHit = false,
		CharacterCount = 5,
		AttackDebounce = 0.3,

		Linger = 1.2,
		Hit = {},}
	local hitboxobj = HitM.New(Properties)
		local HitResult, EnemyChar = table.unpack(hitboxobj:StartHitbox())
	
		print(HitResult, EnemyChar)
		
		return HitResult, EnemyChar

Un-fortunately, there’s really not an actual change yet.

local hitboxobj = HitM.New({Size = Vector3.new(3.5, 4.25, 4),
        Position = Player.Character.HumanoidRootPart,
        Attacker = Player.Character,
        InUse = true,
        Despawn = true,
        DespawnTime = tick(),
        Activity = true,
        MultiHit = false,
        CharacterCount = 5,
        AttackDebounce = 0.3,

        Linger = 1.2,
        Hit = {},})
        local HitResult, EnemyChar = hitboxobj:StartHitbox()
        local temp = {HitResult, EnemyChar}
        print(HitResult, EnemyChar)
        
        return temp

script receiving ‘temp’

local HitResult, EnemyChar = table.unpack(functionnamethingidkididntwritethisscript)

So quick question, on the actual module getting the character in a hitbox, and placing the values in a table, or make them come in seperately?

put the values in a table then return that table.
then when you receive the table, use table.unpack()

documentation

image


I decided only to send the receiving script, because I believe I fixed the rest to work the way you are explaining so.
image

hm in the the receiving script try this:

local temp = table.unpack(Presets.HandToHandHitbox(Params.Player))
local HitResult = temp[1]
local STHitbox = temp[2]

I will not lie to you, I didn’t test this, and the reason is that it’s already acknowledged whatever is in the return getting sent over is getting seen as nil, so I just don’t believe this will work.

Any further assistance? Been doing some work behind the scenes, but nothing comes to fruition.