Module constantly returning nil

I want to have this module return the target player. The target isn’t nil but the minute it returns when I get the target on the server it is nil.

local target = part.Parent
print(target)

if target ~= nil then
 print("returning target")
 return target
end

The target comes up as the intended player target (a dummy) and then prints returning target but on the server

target = HitDetection.magnitude(character, 5, {
					frames = 2,
					cone = 0.6
				})
			
			    print(target)

Comes up as nil

Please help if anyone has any ideas.

Is that in a function, if not this won’t work.

Yes, it’s in a function inside the module