hitBox Touched Finding Target

howdy mates! If you have time, and I mean A LOT

I’m having problems on detecting a target when a player touches the Hitbox.

Even though there is a target touching the Hitbox, it’ll still come out as “Target Not Found” I’ve tried many ways to fix this issue, but it just doesn’t seem to work… and it feels like I’m missing something.

--Grabbing the player
	userAnimation:GetMarkerReachedSignal("GrabEvent"):Connect(function()
		task.delay(Handler.HitboxLifeTime, function()
			--IF target is not FOUND
			if not Handler.confirmTarget[player.Name] then
				
				print("Target not found")
				
				canLaunch = false
				
				--Grabbing process
				task.delay(Handler.Cooldown, function()
					
					canLaunch = true
					
					if Handler.playerDebounce[player.Name] then
						Handler.playerDebounce[player.Name] = nil
					end
					
					if Handler.confirmTarget[player.Name] then
						Handler.confirmTarget[player.Name] = nil
					end
				end)
				
				--Cooldown
				GRe:FireClient(player, Handler.Cooldown)
			else
				--If Target is FOUND
				if Handler.confirmTarget[player.Name] then
					print("Target spotted")
					canLaunch = true
					task.delay(Handler.grabDuration, function()

						--Grabbing
						if Handler.confirmTarget[player.Name] then
							Handler.confirmTarget[player.Name] = nil
						end

						if Handler.playerDebounce[player.Name] then
							Handler.playerDebounce[player.Name] = nil
						end

						--cooldown
						GRe:FireClient(player, Handler.Cooldown)
					end)
				end
			end
		end)

And here is the Hitbox Modular

local connection = hitBox.Touched:Connect(function() end)
	
	local results = hitBox:GetTouchingParts()
	coroutine.wrap(function()
		for i = 1, #results do
			local obj = results[i]
			if not obj:IsDescendantOf(character) then
				local enemyHum = obj.Parent:FindFirstChild("Humanoid")
				local enemyRoot = obj.Parent:FindFirstChild("HumanoidRootPart")
				
				if enemyHum and enemyRoot and enemyHum.Health > 0 then
					if Handler.confirmTarget[player.Name] then
						return
					end
					
					Handler.confirmTarget[enemyHum.Parent.Name] = true
					
					local targetAnim = Handler.playAnimations(enemyHum, "Target")
					targetAnim:Play()
					
					--Damage
					coroutine.wrap(function()
						local canTick = true
						task.delay(EffectsHanlder.grabDuration, function()
							canTick = false
						end)
						while true do
							if not canTick then
								break
							end
							
							enemyHum:TakeDamage(Handler.damage)
							
							local infoTable = {
								character = enemyHum.Parent,
								rootPart = enemyRoot
							}
							
							
							VFXRe:FireAllClients("FireBurstVFX", infoTable)
							
							task.wait(Handler.grabDuration / Handler.tickRate)
						end
					end)()
					
					if connection then
						connection:Disconnect()
					end
					
					return
				end
			end
		end
	end)()

And like I said if you do have much time… Please, do correct me from my errors… What am I missing/is the problem here?

2 Likes

First line of the hitbox module appears to end the function without actually running it.

1 Like