Issue with ragdolls, shiftlock becoming smooth

Hello, i need help with this simple ragdoll system, i have this weird issue where the shiftlock becomes “smooth”, almost like it’s being lerped

Here’s a video of whats happening, because its hard to explain

Before ragdolling, the shiftlock is working like normal, but after i ragdoll it just gets turned into this. After resetting it goes back to normal.
I tried using ChatGPT and Claude to fix this but even the AI wasn’t able to fix it.

Im pretty sure the BuildJoints function is the one that’s causing the issue, but im not too sure about this.
This is my script:


local RagdollService = {}

local RagdollOffsets = {
	Head = {
		CFrame = {CFrame.new(0, 1, 0, 0, -1, 0, 1, 0, -0, 0, 0, 1), CFrame.new(0, -0.5, 0, 0, -1, 0, 1, 0, -0, 0, 0, 1)}
	},
	HumanoidRootPart = {
		CFrame = {CFrame.new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), CFrame.new(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)}
	},
	["Right Arm"] = {
		CFrame = {CFrame.new(1.3, 0.75, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1), CFrame.new(-0.2, 0.75, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)}
	},
	["Left Arm"] = {
		CFrame = {CFrame.new(-1.3, 0.75, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1), CFrame.new(0.2, 0.75, 0, -1, 0, 0, 0, -1, 0, 0, 0, 1)}
	},
	["Right Leg"] = {
		CFrame = {CFrame.new(0.5, -1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1), CFrame.new(0, 1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1)}
	},
	["Left Leg"] = {
		CFrame = {CFrame.new(-0.5, -1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1), CFrame.new(0, 1, 0, 0, 1, -0, -1, 0, 0, 0, 0, 1)}
	}
}

RagdollService.Ragdolled = false

function RagdollService:SetMotor6Ds(Character: Model, Enable: BoolValue)
	for _, Motor6D in pairs(Character:GetDescendants()) do
		if not Motor6D:IsA("Motor6D") then
			continue
		end
		if Motor6D.Name == "Handle" or Motor6D.Name == "RootJoint" then
			continue
		end
		Motor6D.Enabled = Enable
	end
end

function RagdollService:SetupHumanoid(Character: Model)
	local Humanoid = Character:FindFirstChild("Humanoid")
	if Humanoid then
		Humanoid.BreakJointsOnDeath = false
		Humanoid.RequiresNeck = false
	end
end

function RagdollService:BuildJoints(Character: Model)
	local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
	for _, stuff in Character:GetDescendants() do
		if not RagdollOffsets[stuff.Name] then
			continue
		end
		
		local A1: Attachment, A0: Attachment = Instance.new("Attachment"), Instance.new("Attachment")
		
		A0.Parent = stuff
		A0.CFrame = RagdollOffsets[stuff.Name].CFrame[2]

		
		A1.Parent = HumanoidRootPart
		A1.CFrame = RagdollOffsets[stuff.Name].CFrame[1]
		
		A0.Name, A1.Name = "RAGDOLLATTACHMENT", "RAGDOLLATTACHMENT"
		
		print("Created attachments for:", stuff.Name)
		
		local Joint: BallSocketConstraint = Instance.new("BallSocketConstraint")
		Joint.Parent = stuff
		Joint.Attachment0 = A0
		Joint.Attachment1 = A1
		Joint.Name = "RAGDOLLCONSTRAINT"
		Joint.Enabled = true
		
		stuff.Massless = true
	end
end

function RagdollService:CreateCollisionParts(Character: Model)
	for _, Part in pairs(Character:GetDescendants()) do
		if Part:IsA("BasePart") then
			local P = Part:Clone()
			P.Parent = Part
			P.Size = Vector3.one
			P.Massless = true
			P.CanCollide = false
			P.Transparency = 1
			P.Name = "RagdollPart"
			P:ClearAllChildren()
			
			local Weld = Instance.new("Weld")
			Weld.Parent = P
			Weld.Part0 = P
			Weld.Part1 = Part
		end
	end
end

function RagdollService:EnableCollisionParts(Character : Model, Enabled : BoolValue)
	for _, Part in pairs(Character:GetDescendants()) do
		if Part.Name == "RagdollPart" then
			Part.CanCollide = Enabled
		end
	end
end

function RagdollService:DestroyJoints(Character: Model)
	for _, stuff in Character:GetDescendants() do
		if stuff.Name == "RAGDOLLATTACHMENT" or stuff.Name == "RAGDOLLCONSTRAINT" then
			stuff:Destroy()
		end
	end
end

function RagdollService:Ragdoll(Character : Model, Duration : number)
	RagdollService.Ragdolled = true
	
	local Player = game.Players:GetPlayerFromCharacter(Character)
	local Humanoid : Humanoid = Character:FindFirstChild("Humanoid")
	local HumanoidRootPart : Part = Character:FindFirstChild("HumanoidRootPart")
	
	if not HumanoidRootPart or not Duration then
		return
	end

	if Player then
		HumanoidRootPart:SetNetworkOwner(nil)
		Humanoid.PlatformStand = true
		Humanoid.AutoRotate = false
	else
		HumanoidRootPart:SetNetworkOwner(Player)
		Humanoid.PlatformStand = true
		Humanoid.AutoRotate = false
	end
	
	RagdollService:SetMotor6Ds(Character, false)
	RagdollService:BuildJoints(Character) -- It seems to be that this part is causing the issue but im not sure what to do to resolve it.
	RagdollService:EnableCollisionParts(Character, true)
	Humanoid.JumpPower = 0
	task.wait(Duration)
	Humanoid.JumpPower = 50
	RagdollService:UnRagdoll(Character)
	
	RagdollService.Ragdolled = false
end



function RagdollService:UnRagdoll(Character: Model)
	local Player = game.Players:GetPlayerFromCharacter(Character)
	local Humanoid : Humanoid = Character:FindFirstChild("Humanoid")
	local HumanoidRootPart : Part = Character:FindFirstChild("HumanoidRootPart")
	
	if not HumanoidRootPart then
		return
	end
	
	if Player then
		HumanoidRootPart:SetNetworkOwner(Player)
		if Humanoid:GetState() == Enum.HumanoidStateType.Dead then
			return
		end
		Humanoid.PlatformStand = false
	else
		HumanoidRootPart:SetNetworkOwner(nil)
		if Humanoid:GetState() == Enum.HumanoidStateType.Dead then
			return
		end
		Humanoid.PlatformStand = false
	end
	
	RagdollService:SetMotor6Ds(Character, true)
	RagdollService:DestroyJoints(Character)
	RagdollService:EnableCollisionParts(Character, false)
	
	
	Humanoid.AutoRotate = true
end

return RagdollService


3 Likes