The reaction time of the hitbox is off

robloxapp-20240107-1844296.wmv (856.9 KB)
The hitbox reacts slowly to the player’s movement, how can i make it move instantaneously?
code:

game.Players.PlayerAdded:Connect(function(player)
	wait(0.6)
	local plr = player.Character
	local hitbox = Instance.new("Part")
	hitbox.Anchored = true
	hitbox.CanCollide = false
	hitbox.Name = "PlayerHealthHitbox"
	hitbox.Color = Color3.new(1, 0, 0)
	hitbox.Transparency = 0.6
	hitbox.Parent = plr
	print(hitbox.Parent)
	if player:WaitForChild("leaderstats").Equipped.Value == 1 then
		hitbox.Size = Vector3.new(4.5, 5.75, 3)
	end
	while wait() do
		local plr = player.Character
		local x = plr.HumanoidRootPart.Position.X
		local y = plr.HumanoidRootPart.Position.Y
		local z = plr.HumanoidRootPart.Position.Z
		local x2 = plr.HumanoidRootPart.Orientation.X
		local y2 = plr.HumanoidRootPart.Orientation.Y
		local z2 = plr.HumanoidRootPart.Orientation.Z
		hitbox.Position = Vector3.new(x, y, z)
		hitbox.Orientation = Vector3.new(x2, y2, z2)
	end
end)

Have you checked the reply I made on your other post? Try using a WeldConstraint.

Code:

game.Players.PlayerAdded:Connect(function(player)
	task.wait(0.6)
	local plr = player.Character
	local hitbox = Instance.new("Part")
	hitbox.Anchored = true
	hitbox.CanCollide = false
	hitbox.Name = "PlayerHealthHitbox"
	hitbox.Color = Color3.new(1, 0, 0)
	hitbox.Transparency = 0.6
	hitbox.Parent = plr
	print(hitbox.Parent)
	if player:WaitForChild("leaderstats").Equipped.Value == 1 then
		hitbox.Size = Vector3.new(4.5, 5.75, 3)
	end
	
	local weldConstraint = Instance.new("WeldConstraint")
	weldConstraint.Part0 = hitbox
	weldConstraint.Part1 = plr.HumanoidRootPart
	weldConstraint.Parent = hitbox
end)

I didn’t know you can solve that with a weld, sorry :frowning: