Flinging in a Combat System

I want to prevent flinging in a combat system no idea how. I dont know what approach to take to solve this issue…

External Media

Any tips on what i can do ? The combat system it self is well over 500 lines so this is a part I think would cause the issue ```lua

function HitHandler.CreateHitbox(player, attackType, lookVector)
if not player or not player:IsA(“Player”) or not attackDamages[attackType] then
return
end

local userId = player.UserId
playerHitboxes[userId] = playerHitboxes[userId] or {}
local playerData = playerHitboxes[userId]
local currentTime = tick()
local lastHitboxTime = playerData[attackType] or 0
local cooldown = HitHandler.GetCooldown(attackType) or 0
if currentTime - lastHitboxTime < cooldown then
	return
end
playerData[attackType] = currentTime + cooldown

local character = player.Character or player.CharacterAdded:Wait()
SpeedManager:applySlow(character, 0.2, 0.5)
local humanoidRootPart = character:WaitForChild("HumanoidRootPart")
local hitbox = Instance.new("Part", character)
hitbox.Size = Vector3.new(5, 5, 5)
hitbox.CanCollide = false
hitbox.Anchored = true
hitbox.Transparency = 0.8
hitbox.Material = Enum.Material.SmoothPlastic
hitbox.Massless = true
hitbox.BrickColor = BrickColor.Red()
hitbox.Position = humanoidRootPart.Position + (humanoidRootPart.CFrame.LookVector * 2)

local hasHit = false

hitbox.Touched:Connect(function(hit)
	if hasHit then return end

	local hitCharacter = hit.Parent
	local hitHumanoid = hitCharacter:FindFirstChildOfClass("Humanoid")
	if hitHumanoid and hitCharacter ~= character then
		hasHit = true

		local forceMagnitude = 5
		local forceMagnitudeEnemy = 5

		local function isAttackFromFront(character, attackerPosition)
			local characterFacingDirection = character.HumanoidRootPart.CFrame.LookVector
			local attackDirection = (attackerPosition - character.HumanoidRootPart.Position).unit
			local dotProduct = characterFacingDirection:Dot(attackDirection)

			return dotProduct > 0
		end

		local processedCharacters = {}
		if hitHumanoid.Parent:GetAttribute("IsBlocking") == true and isAttackFromFront(hitHumanoid.Parent, player.Character.HumanoidRootPart.Position) then
			local characterId = hitHumanoid.Parent:GetAttribute("UserId") or hitHumanoid.Parent.Name

			if not processedCharacters[characterId] then
				processedCharacters[characterId] = true

				if hitHumanoid.Parent:GetAttribute("PerfectBlock") == true then
					task.wait()
					PerfectBlockParticles(hitHumanoid)
				else
					local blockCount = hitHumanoid.Parent:GetAttribute("BlockCount") or 0
					blockCount = blockCount + 1

					if blockCount >= 5 then
						hitHumanoid.Parent:SetAttribute("BlockCount", 0)
						task.wait()
						BlockBreakParticles(hitHumanoid)
					else
						hitHumanoid.Parent:SetAttribute("BlockCount", blockCount)
						task.wait()
						BlockParticles(hitHumanoid)
					end
				end
				return
			end
		end

		applyKnockback(hitCharacter, lookVector, attackType)
		server:Fire(BridgeNet.AllPlayers(), { hit = true, playerName = player.Name })

		applyForce(hitHumanoid.Parent, (hitHumanoid.Parent.HumanoidRootPart.Position - player.Character.HumanoidRootPart.Position).unit, forceMagnitudeEnemy)
		SpeedManager:applySlow(hitHumanoid.Parent, 0.2, 1)
		applyForce(player.Character, (player.Character.HumanoidRootPart.Position - hitHumanoid.Parent.HumanoidRootPart.Position).unit, -forceMagnitude)
		SpeedManager:applySlow(player.Character, 0.2, 0.3)

		if not hitCharacter:GetAttribute("AlreadyHitBy" .. attackType) then
			hasHit = true

			hitHumanoid:TakeDamage(attackDamages[attackType])
			hitCharacter:SetAttribute("AlreadyHitBy" .. attackType, true)

			applyStunEffect(hitCharacter, attackType)
			HitHandler.ApplyDisableEffect(hitCharacter, attackType)
			
			local damageAmount = attackDamages[attackType]
			local playerUserId = player.UserId

			Data:FireClient(player, {action = "damageIndicator", damageAmount = damageAmount, hitPosition = hitCharacter.HumanoidRootPart.Position})
			
			local sfxName = attackType
			local sfxToPlay = RS:WaitForChild("SFX"):FindFirstChild(sfxName)

			if sfxToPlay then
				sfxToPlay:Play()
			else
				warn("SFX needs to be named the same as the animation")
			end

			local desiredHeight = 15
			local freezeDuration = 2

			if attackType == "Uplift" then
				upliftAndFreezeCharacter(character, desiredHeight, false)
				upliftAndFreezeCharacter(hitCharacter, desiredHeight, false)
				emitParticlesUplift(player.Character)
				SpeedManager:applySlow(character, 0.2, 2)
				SpeedManager:applySlow(hitCharacter, 0.2, 2)
				delay(2, function()
					upliftAndFreezeCharacter(character, nil, true, "Air3")
					upliftAndFreezeCharacter(hitCharacter, nil, true, "Air3")
				end)
			end
			if attackType ~= "Uplift" then
				emitParticles(hitCharacter)
			end

			if attackType == "Air3" then
				upliftAndFreezeCharacter(hitCharacter, nil, true, "Air3")
				upliftAndFreezeCharacter(character, nil, true, "Air3")
			end

			delay(0.1, function()
				if hitCharacter then
					hitCharacter:SetAttribute("AlreadyHitBy" .. attackType, nil)
				end
			end)
			
			hitbox:Destroy()
		end
	end

end)
task.delay(0.2, hitbox.Destroy, hitbox)

end