C0 in Skinned Mesh?

So, I’m making a sonic game and to do so i have to make the player rotate to the slope they’re standing on, but when the script was made it has only regular rigs in mind. (i, e Robloxians, any character using Motor6Ds) But I’ve moved to using Skinned Meshes, and they use Bones instead, thus breaking the script. Bones don’t have C0s, so how would i go about rewriting this?

local RunService = game:GetService("RunService")

local Character = script.Parent
local HumanoidRootPart:BasePart = Character:WaitForChild("HumanoidRootPart")
local RootJoint = HumanoidRootPart:WaitForChild("Root")

local RootJointC0 = RootJoint.C0
local RayParams = RaycastParams.new()
RayParams.FilterDescendantsInstances = {Character}

RunService.RenderStepped:Connect(function(deltaTime)
	local RaycastResult = workspace:Raycast(HumanoidRootPart.Position,-Vector3.yAxis*5, RayParams)
	local C0Offset = CFrame.identity 
	if RaycastResult then
		local upVector = RaycastResult.Normal
		local rightVector = HumanoidRootPart.CFrame.RightVector
		local backVector = -HumanoidRootPart.CFrame.LookVector
		local calculationForX = CFrame.fromMatrix(Vector3.zero,rightVector,upVector)
		local calculationForZ = CFrame.fromMatrix(Vector3.zero,backVector,upVector)
		local x = calculationForX:ToOrientation()
		local z = calculationForZ:ToOrientation()

		C0Offset = CFrame.Angles(x,0,z)
	end
	RootJoint.C0 = RootJoint.C0:Lerp(C0Offset*RootJointC0,deltaTime*10)
end)

any ideas would be great

Im not sure if this would work with your current solution since C0 and Transform behave differently, but try:

local RunService = game:GetService("RunService")

local Character = script.Parent
local HumanoidRootPart:BasePart = Character:WaitForChild("HumanoidRootPart")
local RootJoint = HumanoidRootPart:WaitForChild("Root")

local RootJointC0 = RootJoint.C0
local RayParams = RaycastParams.new()
RayParams.FilterDescendantsInstances = {Character}

RunService.PreSimulation:Connect(function(deltaTime)
	local RaycastResult = workspace:Raycast(HumanoidRootPart.Position,-Vector3.yAxis*5, RayParams)
	local TransformOffset = CFrame.identity 
	if RaycastResult then
		local upVector = RaycastResult.Normal
		local rightVector = HumanoidRootPart.CFrame.RightVector
		local backVector = -HumanoidRootPart.CFrame.LookVector
		local calculationForX = CFrame.fromMatrix(Vector3.zero,rightVector,upVector)
		local calculationForZ = CFrame.fromMatrix(Vector3.zero,backVector,upVector)
		local x = calculationForX:ToOrientation()
		local z = calculationForZ:ToOrientation()

		TransformOffset = CFrame.Angles(x,0,z)
	end
	RootJoint.Transform = RootJoint.Transform:Lerp(C0Offset*RootJointC0,deltaTime*10)
end)

Transform is the only way to really move bones so youre gonna need it to work w/ that

I’ve tried it (and fixed the errors), but it just made the character jittery

Oh my bad i forgot smth. Here. Ive tested this and it works, I also suggest you offset the point the ray comes from to the feet so that standing on ledges doesnt make you go completely sideways.

local RunService = game:GetService("RunService")

local Character = script.Parent
local HumanoidRootPart:BasePart = Character:WaitForChild("HumanoidRootPart")
local RootJoint = HumanoidRootPart:WaitForChild("Root")
local RayParams = RaycastParams.new()
RayParams.FilterDescendantsInstances = {Character}

local TransformOffset = CFrame.identity

RunService.PreSimulation:Connect(function(deltaTime)
	local RaycastResult = workspace:Raycast(HumanoidRootPart.Position,-Vector3.yAxis*5, RayParams)
	local target = CFrame.identity
	if RaycastResult then
		local upVector = RaycastResult.Normal
		local rightVector = -HumanoidRootPart.CFrame.RightVector
		local backVector = -HumanoidRootPart.CFrame.LookVector
		local calculationForX = CFrame.fromMatrix(Vector3.zero,rightVector,upVector)
		local calculationForZ = CFrame.fromMatrix(Vector3.zero,backVector,upVector)
		local x = calculationForX:ToOrientation()
		local z = calculationForZ:ToOrientation()

		target = CFrame.Angles(x,z,0)
	end
	
	print(TransformOffset)
	
	TransformOffset = TransformOffset:Lerp(target,deltaTime*10) 
	RootJoint.Transform *= TransformOffset
end)

Please let me know if theres any more issues!

Also forgot to mention that if a animation isnt playing this will bug so make sure theres always a animation playing or create another loop on RunService.PreAnimation that sets the transform to CFrame.identitiy.

Have you tried using the new roblox update instead of transforming the bones in a loop?

Thats for Ragdolls and Physically simulated limbs.

it works! its a little buggy on certain angles, turning the player opposite of the way their moving sometimes, but its better than nothing, thanks!!!