Unanchoring Humanoid Root Part causes a freeze/delay effect

  1. What do you want to achieve? I would like the target character to stay a float in the air for a bit, to do this, I have anchored their HRP.

  2. What is the issue? There is a very noticeable freeze effect after unanchoring the part, this still happens if I remove any other code in the tween.Completed function.

  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub? I have attempted to change the network owner yet it doesn’t do anything. I have looked for a solution, but can’t find one.

Code:

(The task.wait(5) is there for debugging, it is not the freeze I am talking about, the freeze I am talking about happens when the red hitbox shows)

	ragdollModule.Start(closestPlayer.Character)
	closestHRP.Anchored = true
	task.wait(.1)
	tween:Play()
	
	tween.Completed:Connect(function()
		task.wait(5)
		closestHRP.Anchored = false
		local hitboxSize = Vector3.new(6, 6, 15)
		local hitboxCFrame = hrp.CFrame * CFrame.new(0, 0, -1.5)
		closestHRP:SetNetworkOwner(closestPlayer)
		hitboxModule.new(chr, hitboxSize, hitboxCFrame, abilityDamage, true)
	end)

Video:

can you show the whole script?

Sure, although it’s not necessary.

local blueAbility = {}

local RepStorage = game:GetService("ReplicatedStorage")
local Plrs = game:GetService("Players")
local StarterPlayer = game:GetService("StarterPlayer")
local Debris = game:GetService("Debris")
local TweenService = game:GetService("TweenService")

local ragdollModule = require(game:GetService("ReplicatedStorage"):WaitForChild("Modules"):WaitForChild("Ragdoll"))

local blueVFXPart = RepStorage:WaitForChild("VFX"):WaitForChild("Abilities"):WaitForChild("BlueVFXPart")

local modules = RepStorage:WaitForChild("Modules")
local vfxModule = require(modules:WaitForChild("VFXEmitter"))
local hitboxModule = require(modules:WaitForChild("HitboxCreator"))

local DEBOUNCE_WALKSPEED = 0
local DEFAULT_WALKSPEED = StarterPlayer.CharacterWalkSpeed

--local soundTemplate = RepStorage:WaitForChild("Sounds"):WaitForChild("BlueSFX")

local function findClosestPlayer(searcherHRP: Part, maxDistance2: number)
	local maxDistance = maxDistance2
	local players = Plrs:GetPlayers()
	local closestPlayerDistance = maxDistance
	local closestPlayer, closestHRP
	
	for i, player in ipairs(players) do
		local character = player.Character
		if character then
			local playerHRP: Part = character:FindFirstChild("HumanoidRootPart")
			if playerHRP and playerHRP ~= searcherHRP then
				local distance = (playerHRP.Position - searcherHRP.Position).Magnitude
				if distance <= maxDistance and distance < closestPlayerDistance then
					closestPlayer = player
					closestHRP = playerHRP
					closestPlayerDistance = distance
				end
			end
		end
	end
	
	return closestPlayer, closestHRP
end

function blueAbility.new(plr: Player, abilityName, abilityDamage, animLength)
	local chr = plr.Character or plr.CharacterAdded:Wait()
	local hum: Humanoid = chr:WaitForChild("Humanoid")
	local hrp: BasePart = chr:WaitForChild("HumanoidRootPart")
	
	print("Module blue!")

	--[[local soundClone = soundTemplate:Clone()
	soundClone.Parent = hrp
	soundClone:Play()

	Debris:AddItem(soundClone, soundClone.TimeLength)]]

	task.spawn(function()
		hum.WalkSpeed = DEBOUNCE_WALKSPEED
		task.wait(animLength)
		hum.WalkSpeed = DEFAULT_WALKSPEED
	end)

	local blueVFXClone = blueVFXPart:Clone()
	blueVFXClone.CFrame = hrp.CFrame * CFrame.new(0.409, 0.567, -13.183) * CFrame.Angles(0, math.rad(180), 0)
	blueVFXClone.Parent = workspace
	task.wait(.01)
	vfxModule.new(blueVFXClone)
	
	task.wait(.1)
	
	local tweenInfo = TweenInfo.new(
		.4,
		Enum.EasingStyle.Linear,
		Enum.EasingDirection.Out
	)
	
	local closestPlayer, closestHRP: Part? = findClosestPlayer(hrp, 30)
	local targetCFrame = hrp.CFrame * CFrame.new(0, .5, 0) * CFrame.Angles(0, math.rad(180), 0)
	local tween = TweenService:Create(closestHRP, tweenInfo, {
		CFrame = targetCFrame
	})
	
	ragdollModule.Start(closestPlayer.Character)
	closestHRP.Anchored = true
	task.wait(.1)
	tween:Play()
	
	tween.Completed:Connect(function()
		task.wait(5)
		closestHRP.Anchored = false
		local hitboxSize = Vector3.new(6, 6, 15)
		local hitboxCFrame = hrp.CFrame * CFrame.new(0, 0, -1.5)
		closestHRP:SetNetworkOwner(closestPlayer)
		hitboxModule.new(chr, hitboxSize, hitboxCFrame, abilityDamage, true)
	end)
end

return blueAbility

okay so what i would do instead is use alignposition. since the main issue is caused by you anchoring the rootpart.

3 Likes

This fixed the issue, thanks a lot!