So, I have an animation playing, and it’s supposed to position both active HumanoidRootParts to the same CFrame so the animation is aligned. But, when setting the CFrame, both characters aren’t properly aligned (note this offset only happens when someone is moving.) I know this is probably because of latency. how would I set them both to an exact CFrame?
local victimChar = victim.Character
local victimRoot = victimChar:FindFirstChild("HumanoidRootPart")
if victimRoot then
hrp.Anchored = true
victimRoot.Anchored = true
local goal = victimRoot.CFrame
hrp.CFrame = goal
victimRoot.CFrame = goal --Doesn't work
end
local stabAnim = animator:LoadAnimation(script.StabLoop)
stabAnim:Play()
It may be because of the latency of the physics. Making it so that if your setting both humanoid root parts to the same cframe, because of the network replication it may not line up correctly. You can try something like this though
local victimChar = victim.Character
local victimRoot = victimChar and victimChar:FindFirstChild("HumanoidRootPart")
local victimHumanoid = victimChar and victimChar:FindFirstChild("Humanoid")
if victimRoot and victimHumanoid then
-- Freeze both characters completely
hrp.Anchored = true
victimRoot.Anchored = true
-- Ensure the server owns the physics
victimRoot:SetNetworkOwner(nil)
hrp:SetNetworkOwner(nil)
-- Optionally stop animations or physics
victimHumanoid:ChangeState(Enum.HumanoidStateType.Physics)
-- Small wait to allow anchoring to take effect
task.wait() -- or wait(0.05)
-- Now position both exactly
local goal = victimRoot.CFrame
hrp.CFrame = goal
victimRoot.CFrame = goal
-- Play animation
local stabAnim = animator:LoadAnimation(script.StabLoop)
stabAnim:Play()
end