Ragdoll Limbs Lag Behind Torso

I am using CompletedLoop’s Ragdoll Script for my fighting game. Ive noticed, however, it seems that the limbs and head dont follow the torso for other clients and the server. It only shows up correctly for the player who’s ragdolled. I found this out when I activated the ragdoll and kept it active for a few seconds. On both the server and other clients, the torso is the only part the moves. The limbs and head slightly move then stay frozen in one place until ragdoll is deactivated. Maybe this has something to do with the knockback force im giving the character? I dont know. Here are some pieces of code that are related to the issue:

This is part of a script that includes this thing for punching players:

local Char = Humanoid.Parent
local StatManager = require(Char.StatManager)
					
local AttackInfo = {}
AttackInfo.Damage = 10
AttackInfo.Knockback = (HumanoidRootPart.CFrame * CFrame.Angles(math.rad(45), 0, 0)).LookVector * 35
AttackInfo.Stun = .85
AttackInfo.Ragdoll = true
					
local Return = StatManager.TakeDamage(AttackInfo)
if Return == "Hit" or Return == "Kill" then
	local PunchSound = SFX.PunchSound:Clone()
	PunchSound.Parent = Char.HumanoidRootPart
	PunchSound:Destroy()
						
	VFXModule.PunchEffect(Char.HumanoidRootPart)
end

The VFXModule (idk if this is part of the problem or not just being safe and providing everything within this part of the code):

function VFXModule.PunchEffect(Part)
	local Effect = VFX.PunchEffect:Clone()
	Effect.Parent = VFXHolder
	
	Effect.CFrame = Part.CFrame
	
	local Weld = Instance.new("Weld")
	Weld.Part0 = Part
	Weld.Part1 = Effect
	Weld.Parent = Effect
	
	wait()
	Effect.Attachment.Emitter:Emit(1)
	
	Debris:AddItem(Effect, 1)
end

The TakeDamage() Function in the StatsManager Module-Script:

function StatManager.TakeDamage(AttackInfo)
	--Function won't continue if the attack is blocked and is not block-breaking
	if FightMode.Value == 0 or FightMode.Value == 3 then return "CantHit" end
	if StatManager.Blocking == true and not AttackInfo.BlockBreak then return "Blocked" end
	
	local ShieldMult = 1 - math.clamp(StatManager.Shield/100, 0, 1)
	
	if AttackInfo.Stun then
		StatManager.Stun.Tick = tick()
		StatManager.Stun.Time = AttackInfo.Stun
		StatManager.Stun.Ragdoll = AttackInfo.Ragdoll or false
	end
	
	if AttackInfo.Knockback then
		local BodyVelocity = Instance.new("BodyVelocity")
		BodyVelocity.Parent = HumanoidRootPart
		BodyVelocity.MaxForce = Vector3.one * math.huge
		BodyVelocity.Velocity = AttackInfo.Knockback * ShieldMult
		
		Debris:AddItem(BodyVelocity, .1)
	end
	
	StatManager.Health -= AttackInfo.Damage * ShieldMult
	--print(AttackInfo.Damage * ShieldMult)
	
	if StatManager.Health <= 0 then
		return "Kill"
	end
	
	return "Hit"
end

And last but not least, a function that runs every step of the RunService in the StatManager Module-Script:

function OnStep(Time, DeltaTime)
	--print('a')
	if TT > .75 and StatManager.Health > 0 then
		StatManager.Health = math.clamp(StatManager.Health+StatManager.HealthRegen, 0, StatManager.MaxHeatlh)
		TT = 0
	end
	
	Humanoid.Health = StatManager.Health
	Humanoid.MaxHealth = StatManager.MaxHeatlh
	Humanoid.WalkSpeed = StatManager.WalkSpeed
	Humanoid.JumpPower = StatManager.JumpPower
	IsRagdoll.Value = false
	FightMode.Value = 1
	
	if tick() - StatManager.Stun.Tick < StatManager.Stun.Time then
		Humanoid.WalkSpeed = 0
		Humanoid.JumpPower = 0
		IsRagdoll.Value = StatManager.Stun.Ragdoll
		FightMode.Value = 2
	end
	
	TT += DeltaTime
end

Please help! i dont want my fighting game to have this laggy ragdolling in it. I would provide footage, but roblox wont let me for some reason soooo...
1 Like

Technically i can mostly ignore this issue for now, but when i publish the game, I dont want it to have such laggy looks

1 Like

Its a client-server replication issue. The server likely doesnt know that the parts are there and ragdolled, and therefore cannot communicate that to other clients/

1 Like

is there a way to fix this? I saw someone say something about changing network ownership, but when i did that, the ragdoll went crazy and went flying. I dont know if that relates to the same thing or not.

1 Like

That wont work. Are you doing the ragdoll client or serversided?

1 Like

Ive checked the scripts, and it seems that its giving the character joints on the server side, and changes humanoid states on the client side. You can check the script link i put at the top of the post. Its a ragdoll script by CompletedLoop.

Then change humanoid state on the server too.

Doing ragdoll serversided will make other clients see a laggy patchy look always. The only workaround is client sided ragdolls played on all clients, but that can cause issues. Its up to you to figure out how to network your game.