Bug with animations?

So, I have a problem with my character animations when ragdolling, and there’s a very weird thing.

function module:SetRagdoll(Character,Duration)
	if Character:WaitForChild("Humanoid").Health <= 5 then return end
	local Humanoid = Character:WaitForChild("Humanoid")
	local Motors = {}
	local DeleteAfter = {}
	local ragdoll = Instance.new("BoolValue",Character)
	ragdoll.Name = "RagDoll"
	local stun = Instance.new("BoolValue",Character)
	stun.Name = "StunnedStack"
	local finds = {
		"Stunned",
		"Attacking",
	}
--	if Character:FindFirstChild("Carrying") then
--		if workspace:FindFirstChild(Character.Carrying.Value) then
--			print("Found carrying")
--			ssc:UnCarry(game.Players:GetPlayerFromCharacter(Character),workspace[Character.Carrying.Value])
--		end
--	end
	for _,v in pairs(finds) do
		if Character:FindFirstChild(v) then
			Character:FindFirstChild(v):Destroy()
		end	
	end
	for i,v in pairs(Character:GetChildren()) do
		for i,e in pairs(v:GetChildren()) do
			if e:IsA("Motor6D") and v.Name ~= "HumanoidRootPart" and e.Part1 and Character:FindFirstChild(e.Part1.Name) then
				local Array = {e:Clone(),e.Parent}
				table.insert(Motors,Array)
				e:Destroy()
			end
		end
	end
	if not Character.Torso:FindFirstChild("Head") then
		for i,v in pairs(game.ServerStorage.RagdollDummy:GetChildren()) do
			for i,e in pairs(v:GetChildren()) do
				if e:IsA("Attachment") then
					e:Clone().Parent = Character[v.Name]
				end
			end
		end
	end
	Character.Humanoid.PlatformStand = true
	for i,v in pairs(Character:GetChildren()) do
		if v:IsA("BasePart") and v.Name ~= "Torso" and v.Name ~= "HumanoidRootPart" and Character.Torso:FindFirstChild(v.Name) then
			local Joint = Instance.new("BallSocketConstraint",Character.Torso)
			Joint.Attachment0 = Character.Torso[v.Name]
			Joint.Attachment1 = Character[v.Name].Attach
			table.insert(DeleteAfter,Joint)
		end
	end
	if game.Players:FindFirstChild(Character.Name) then
		local Player = game.Players:GetPlayerFromCharacter(Character)
		game.ReplicatedStorage.Remotes.Physics:FireClient(Player,Player,1,false)
	end
	Humanoid:ChangeState(1)
--	Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp,false)
	Character.HumanoidRootPart.CanCollide = false
	
	game.Debris:AddItem(stun,Duration)
	game.Debris:AddItem(ragdoll,Duration)
	Humanoid.AutoRotate = false
	wait(Duration)
		
	if Character:FindFirstChild("Knocked") then return end
	Humanoid.AutoRotate = true
	for i,v in pairs(DeleteAfter) do
		v:Destroy()
	end
	if Character and Humanoid and Humanoid.Health > 0 then
		for i,v in pairs(Motors) do
			v[1].Parent = v[2]
		end
		if Character:FindFirstChild("Humanoid") then
			Character.Humanoid.PlatformStand = false
			Character.HumanoidRootPart.CanCollide = true
			if game.Players:FindFirstChild(Character.Name) then
				local Player = game.Players:GetPlayerFromCharacter(Character)
				game.ReplicatedStorage.Remotes.Physics:FireClient(Player,Player,2,true)
			end
			Humanoid:ChangeState(2)
--			Humanoid:SetStateEnabled(Enum.HumanoidStateType.GettingUp,true)
			for _,v in ipairs(Character:GetDescendants()) do
				if v:IsA("BasePart") then
					print("SEtting")
					v:SetNetworkOwner(game.Players:GetPlayerFromCharacter(Character))
				end
			end
		end
	end
end

return module

This script sucessfully ragdolls and unragdolls, although, there is a slight problem.

After un-ragdolling, the character loses all animations?

Then, the character gains their animations back after a player comes near the animations load again. (This also happens whenever a rig that has an animation controller gets created near, the animations load again.)
What I mean (CLICK)

I’ve tried setting network ownership, I’ve tried disabling, checking states, everything, nothing fixes it.

You can ignore the remote event and the client script, cause even after removing it, the ragdoll still happens and the issue occurs.

I’ve also tried commenting every single line that has anything to do with stopping animations with :GetPlayingAnimationTracks() etc, nothing changes it.

EDIT 1 : I’ve tested it out in studio, and apparently it works there? https://gyazo.com/3f204f421c516d92837159dbe4a3314a

EDIT 2 : I’ve tried using another ragdoll script, it still happens. When a new player joins, they can see the opponents animations, but I can’t.

EDIT 3 : Their animations are only fixed when coming near ME, when coming near another humanoid, the animation still isn’t fixed.

1 Like