I made this code so making hitboxes in general is as easy as possible by just sending back the table of people who were hit but for whatever reason when I call the function to return the table it says the table is equal to nil. Inside the actual function I can print the table and I won’t get nil so I’m confused.
the original function:
function HitboxService:init(Player : Player,Sent : {any})
local Character = Player.Character
local HitboxData = Sent.Hitbox
local RelativePart = HitboxData.RelativePart
local initrelativepart = HitboxService:FindRelativePart(Character,RelativePart)
local Size = initrelativepart.Size * Vector3.new(1.5,1.5,1.5)
local Position = initrelativepart.CFrame
local HitboxParameters = {
SizeOrPart = Size;
UseClient = Player;
DebounceTime = .45;
Blacklist = {Character};
InitialPosition = Position;
Debug = true;
} :: HitboxTypes.HitboxParams
local newHitbox,connected = HitboxClass.new(HitboxParameters)
newHitbox:WeldTo(initrelativepart)
local ReturnTable
newHitbox.HitSomeone:Connect(function(VictimisedCharacters)
ReturnTable = VictimisedCharacters
end)
newHitbox:Start()
coroutine.wrap(function()
wait(.45)
newHitbox:Destroy()
end)()
return ReturnTable
end
where I call it:
local HitTable = HitboxService:init(Player,CurrentInfo)
print(HitTable)