Issue with skill script

local anim1 = script.Animationvurdu
local anim2 = script.vurmadi
local isMoving = false
local don = false
local dokunabiliristerse = false

-- Bu değişken hitbox'un kilitli olup olmadığını kontrol eder
local hitboxLocked = false

game.ReplicatedStorage.ulti1.OnServerEvent:Connect(function(plr)
	local chr = plr.Character
	wait(0.1)

	-- Eğer hitbox zaten kilitliyse işleme devam etmeyin
	if hitboxLocked then
		return
	end

	-- Karakterin stun, block veya ozlyiyor değerleri kontrol ediliyor
	if chr:FindFirstChild("Stun") == nil and chr:FindFirstChild("block") == nil and chr:FindFirstChild("ozlyiyor") == nil then
		-- Hitbox kilitleniyor
		hitboxLocked = true

		local animt = plr.Character.Humanoid:LoadAnimation(anim2)
		animt:Play()
		local character = plr.Character
		local humanoidRootPart = plr.Character.HumanoidRootPart
		local ses = require(game.ReplicatedStorage.demusbabosesmodul)

		-- Devam eden işlem
		 stunkarsi3 = Instance.new("BoolValue", plr.Character)
		stunkarsi3.Name = "ozl"
		stunkarsi31 = Instance.new("BoolValue", plr.Character)
		stunkarsi31.Name = "Dokunulamaz"
		local moveSpeed = 100
		local startTime = tick()
		local hb = Instance.new("Part", workspace)
		hb.Transparency = 1
		hb.BrickColor = BrickColor.new("Really red")
		hb.Anchored = false
		hb.CanCollide = false
		hb.CanTouch = true
		hb.CFrame = humanoidRootPart.CFrame + (humanoidRootPart.CFrame.LookVector * 3)
		hb.Massless = true
		hb.Size = Vector3.new(5, 2, 5)
		local dokundu = false


		hb.Touched:Connect(function(hit)
			if hit.Parent:FindFirstChild("Humanoid") and hit.Parent ~= plr.Character then
				if dokundu == false and hit.Parent:FindFirstChild("Dokunulamaz") == nil then
					dokundu = true
humanoidRootPart.Anchored = true
wait(0.1)
					-- Modül ve stun işlemleri
					modulleeeee = require(game.ReplicatedStorage.ModulesUlti.Ragdoll)
					modulleeeee.Stop(hit.Parent)

					 stunkarsi = Instance.new("BoolValue", hit.Parent)
					stunkarsi.Name = "Stun"
					stunkarsi38 = Instance.new("BoolValue", chr)
					stunkarsi38.Name = "Stun"
					-- Velocity ve highlight ekleniyor
					bvhandler = Instance.new("BodyVelocity", hit.Parent:FindFirstChild("HumanoidRootPart"))
					bvhandler.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
					bvhandler.Velocity = humanoidRootPart.CFrame.LookVector * 0
humanoidRootPart.Anchored = false
					 highlight = Instance.new("Highlight")
					highlight.Parent = hit.Parent
					highlight.OutlineTransparency = 0
					highlight.FillTransparency = 0.5
					highlight.FillColor = Color3.new(0.75, 0, 0)
					highlight.OutlineColor = Color3.new(1, 0, 0)

					-- Highlight yok ediliyor
					task.delay(0.1, function()
						highlight:Destroy()
						humanoidRootPart.Anchored = false
						local targetCFrame = chr:FindFirstChild("HumanoidRootPart").CFrame
						local currentCFrame = hit.Parent:FindFirstChild("HumanoidRootPart").CFrame
						hit.Parent.HumanoidRootPart.CFrame = humanoidRootPart.CFrame * CFrame.new(0,0,-1.6)
						wait(0.1)
						
					end)
					stunkarsi33333 = Instance.new("BoolValue", hit.Parent)
					stunkarsi33333.Name = "ozl"
					-- Ses ve animasyon işlemleri
					ses.olustur(script["Grab Sound"].SoundId, hit.Parent.HumanoidRootPart)
					game.ReplicatedStorage.mordecutsceneremote:FireClient(plr, humanoidRootPart, game.ReplicatedStorage.SAAA)
					hit.Parent.HumanoidRootPart.CFrame = humanoidRootPart.CFrame * CFrame.new(0,0,-1.6)
					animt:Stop()
					hit.Parent.HumanoidRootPart.Anchored = true
					humanoidRootPart.Anchored = true
					-- İkinci animasyon
					local animt2 = plr.Character.Humanoid:LoadAnimation(anim1)
					animt2:Play()

					-- Ana animasyon KeyframeReached olayını işliyor
					animt2.KeyframeReached:Connect(function(keyframe)
						
						if keyframe == "Hitnormal" then
							hit.Parent.HumanoidRootPart.Anchored = false
							humanoidRootPart.Anchored = false
							modulleeeee.Start(hit.Parent)
							hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
							bvhandler:Destroy()
							modulleee = require(game.ReplicatedStorage.ModulesUlti.Ragdoll)
							 bvhandler2 = Instance.new("BodyVelocity", hit.Parent:FindFirstChild("HumanoidRootPart"))
							bvhandler2.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
							bvhandler2.Velocity = humanoidRootPart.CFrame.LookVector * 60
							ses.olustur(script["Punch Kit Beefy Hit 2 (SFX)"].SoundId, hit.Parent.HumanoidRootPart)

							wait(0.5)
							bvhandler2:Destroy()
							wait(0.2)
							modulleeeee.Stop(hit.Parent)

						elseif keyframe == "Hit" then
							-- Ek animasyon ve hasar işlemleri
							bvhandler2:Destroy()
							hit.Parent:FindFirstChild("Humanoid"):TakeDamage(20)
							ses.olustur(script["Punch Kit Beefy Hit 3 (SFX)"].SoundId, hit.Parent.HumanoidRootPart)

							bvhandler3 = Instance.new("BodyVelocity", hit.Parent:FindFirstChild("HumanoidRootPart"))
							bvhandler3.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
							bvhandler3.Velocity = humanoidRootPart.CFrame.LookVector * -100
							modulleee.Start(hit.Parent)

						elseif keyframe == "End" then
							-- İşlem tamamlandıktan sonra temizleme
							bvhandler3:Destroy()
							stunkarsi:Destroy()
							modulleee.Stop(hit.Parent)
							stunkarsi33333:Destroy()
							stunkarsi38:Destroy()
							wait(1)
							
							stunkarsi:Destroy()
						end
					end)
				end
			end
		end)

	
		local weld = Instance.new("WeldConstraint", hb)
		weld.Part0 = hb
		weld.Part1 = humanoidRootPart
		wait(1)
		hb:Destroy()
		weld:Destroy()
		stunkarsi3:Destroy()
stunkarsi31:Destroy()
		
		hitboxLocked = false
	end
end)

hi i have an issue in this code so when the hitbox touches a humanoid its humanoidrootpart comes to infront of my players root part but sometimes when i use this after the dash or after another skill it sometimes comes behind my player or somewhere else how can i fix this

Oh my god please invest in module scripts. And probablt when you bring the character you might have to use a weld constraint and weld the hit root to where you want since anchoring it could cause problems.