Changing Motor6D.C0 By A Script Breaks Animation

The animation and the script were working before. This happened 1 years ago and I solved the problem by enabling workspace.AnimationWeightBlendFix.

The script makes the UpperTorso.Waist.C0 follow the player’s mouse. This is what the animation and the script should do, and it worked before:

But now I looked like this:

As you can see the arms are not following the UpperTorso.

I search for the cause and the solutions for it. It turns out the workspace.AnimationWeightBlendFix Was removed. And the list of solution was given was: Changing the Weight and Animationtrack.Property, unfortunately, it didn’t work in my case.

After doing more research I found something interesting, I found out that old animations are not affected by the “FollowMouseScript” that I have. I have Another tool was been made since 2019 and has the same animation until today. This is also a good example of what I am trying to achieve from the start.

So this is my “Follow Mouse Script”(Local Script):


wait()

--[Pre-Funcs]:
local tweenService = game:GetService("TweenService")
local Ang = CFrame.Angles	--[Storing these as variables so I dont have to type them out.]
local aSin = math.asin
local aTan = math.atan

--[Constants]:

local Cam = game.Workspace.CurrentCamera

local Plr = game.Players.LocalPlayer
local Mouse = Plr:GetMouse()
local Body = Plr.Character or Plr.CharacterAdded:wait()
local Head = Body:WaitForChild("Head")
local Hum = Body:WaitForChild("Humanoid")
local Core = Body:WaitForChild("HumanoidRootPart")
local IsR6 = (Hum.RigType.Value==0)	--[Checking if the player is using R15 or R6.]
local Trso = (IsR6 and Body:WaitForChild("Torso")) or Body:WaitForChild("UpperTorso")
local Neck = (IsR6 and Trso:WaitForChild("Neck")) or Head:WaitForChild("Neck")	--[Once we know the Rig, we know what to find.]
local Waist = (not IsR6 and Trso:WaitForChild("Waist"))	--[R6 doesn't have a waist joint, unfortunately.]

--[[
	[Whether rotation follows the camera or the mouse.]
	[Useful with tools if true, but camera tracking runs smoother.]
--]]
local MseGuide = true
--[[
	[Whether the whole character turns to face the mouse.]
	[If set to true, MseGuide will be set to true and both HeadHorFactor and BodyHorFactor will be set to 0]
--]]
local TurnCharacterToMouse = true
--[[
	[Horizontal and Vertical limits for head and body tracking.]
	[Setting to 0 negates tracking, setting to 1 is normal tracking, and setting to anything higher than 1 goes past real life head/body rotation capabilities.]
--]]
local HeadHorFactor = 0
local HeadVertFactor = 0
local BodyHorFactor = 0
local BodyVertFactor = 1.6

--[[
	[How fast the body rotates.]
	[Setting to 0 negates tracking, and setting to 1 is instant rotation. 0.5 is a nice in-between that works with MseGuide on or off.]
	[Setting this any higher than 1 causes weird glitchy shaking occasionally.]
--]]
local UpdateSpeed = 0.5

local NeckOrgnC0 = Neck.C0	--[Get the base C0 to manipulate off of.]
local WaistOrgnC0 = (not IsR6 and Waist.C0)	--[Get the base C0 to manipulate off of.]

--[Setup]:

Neck.MaxVelocity = 1/3

-- Activation]:
if TurnCharacterToMouse == true then
	MseGuide = true
	HeadHorFactor = 0
	BodyHorFactor = 0
end

game:GetService("RunService").RenderStepped:Connect(function()
	if Hum.Health > 0 then
		local CamCF = Cam.CoordinateFrame
		if ((IsR6 and Body["Torso"]) or Body["UpperTorso"])~=nil and Body["Head"]~=nil then	--[Check for the Torso and Head...]
			local TrsoLV = Trso.CFrame.lookVector
			local HdPos = Head.CFrame.p
			if IsR6 and Neck or Neck and Waist then	--[Make sure the Neck still exists.]
				if Cam.CameraSubject:IsDescendantOf(Body) or Cam.CameraSubject:IsDescendantOf(Plr) then
					local Dist = nil;
					local Diff = nil;
					if not MseGuide then	--[If not tracking the Mouse then get the Camera.]
						Dist = (Head.CFrame.p-CamCF.p).magnitude
						Diff = Head.CFrame.Y-CamCF.Y
						if not IsR6 then	--[R6 and R15 Neck rotation C0s are different; R15: X axis inverted and Z is now the Y.]
							Waist.C0 = Waist.C0:lerp(WaistOrgnC0*Ang((aSin(Diff/Dist)*BodyVertFactor), -(((HdPos-CamCF.p).Unit):Cross(TrsoLV)).Y*BodyHorFactor, 0), UpdateSpeed/2)
						end
					else
						local Point = Mouse.Hit.p
						Dist = (Head.CFrame.p-Point).magnitude
						Diff = Head.CFrame.Y-Point.Y
						if not IsR6 then
							Waist.C0 = Waist.C0:lerp(WaistOrgnC0*Ang(-(aTan(Diff/Dist)*BodyVertFactor), (((HdPos-Point).Unit):Cross(TrsoLV)).Y*BodyHorFactor, 0), UpdateSpeed/2)
						end
					end
				end
			end
		end
	end
	if TurnCharacterToMouse == true then
		Hum.AutoRotate = false
		Core.CFrame = Core.CFrame:lerp(CFrame.new(Core.Position, Vector3.new(Mouse.Hit.p.x, Core.Position.Y, Mouse.Hit.p.z)), UpdateSpeed / 2)
	else
		Hum.AutoRotate = true
	end
end)

game.ReplicatedStorage.Events.CharacterEvents.Look.OnClientEvent:Connect(function(otherPlayer, waistCFrame)
	local Waist = otherPlayer.Character:FindFirstChild("Waist", true)
	if Waist then
		tweenService:Create(Waist, TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0), {C0 = waistCFrame}):Play()
	end
end)

And this how the the animation is being played(Script):

event4.OnServerEvent:Connect(function(player, boolen)
	local anim = Instance.new("Animation")
	anim.AnimationId = "rbxassetid://" .. Hold
	local holdtrack = player.Character:WaitForChild("Humanoid", 1000):LoadAnimation(anim)
	holdtrack.Priority = Enum.AnimationPriority.Action

	if boolen == false then
		equipped.Value = false
		if holdtrack then
			local tracks = player.Character:WaitForChild("Humanoid", 1000):GetPlayingAnimationTracks();
			for i, thistrack in pairs(tracks) do -- Stop and destroy all animations that are playing
				thistrack:Stop();
				thistrack:Destroy();
			end
		end
	end
	if boolen == true then
		equipped.Value = true
		holdtrack:Play()
	end
end)

Is there a way to fix this?

2 Likes

Does it give you any errors? I can’t open the video so I apologize if I ask any silly questions. I’m pretty sure wait() has to be capitalized in CharacterAdded:Wait(). You did this :point_down::point_down:

local Body = Plr.Character or Plr.CharacterAdded:wait()

Do this instead :point_down::point_down::point_down:

local Body = Plr.Character or Plr.CharacterAdded:Wait()

Apologies, I don’t know how to send videos here. I have updated the post; you can see the videos I upload from YouTube, and they are unlisted. And no, it does not give an error.

The problem is in your update function.

<code>local UpdateSpeed = 0.5

-- Activation]:
if TurnCharacterToMouse == true then
	MseGuide = true
	HeadHorFactor = 0
	BodyHorFactor = 0
end

game:GetService("RunService").RenderStepped:Connect(function()
	if Hum.Health &gt; 0 then
		local CamCF = Cam.CoordinateFrame
		if ((IsR6 and Body["Torso"]) or Body["UpperTorso"])~=nil and Body["Head"]~=nil then	--[Check for the Torso and Head...]
			local TrsoLV = Trso.CFrame.lookVector
			local HdPos = Head.CFrame.p
			if IsR6 and Neck or Neck and Waist then	--[Make sure the Neck still exists.]
				if Cam.CameraSubject:IsDescendantOf(Body) or Cam.CameraSubject:IsDescendantOf(Plr) then
					local Dist = nil;
					local Diff = nil;
					if not MseGuide then	--[If not tracking the Mouse then get the Camera.]
						Dist = (Head.CFrame.p-CamCF.p).magnitude
						Diff = Head.CFrame.Y-CamCF.Y
						if not IsR6 then	--[R6 and R15 Neck rotation C0s are different; R15: X axis inverted and Z is now the Y.]
							Waist.C0 = Waist.C0:lerp(WaistOrgnC0*Ang((aSin(Diff/Dist)*BodyVertFactor), -(((HdPos-CamCF.p).Unit):Cross(TrsoLV)).Y*BodyHorFactor, 0), UpdateSpeed/2)
						end
					else
						local Point = Mouse.Hit.p
						Dist = (Head.CFrame.p-Point).magnitude
						Diff = Head.CFrame.Y-Point.Y
						if not IsR6 then
							Waist.C0 = Waist.C0:lerp(WaistOrgnC0*Ang(-(aTan(Diff/Dist)*BodyVertFactor), (((HdPos-Point).Unit):Cross(TrsoLV)).Y*BodyHorFactor, 0), UpdateSpeed/2)
						end
					end
				end
			end
		end
	end
	if TurnCharacterToMouse == true then
		Hum.AutoRotate = false
		Core.CFrame = Core.CFrame:lerp(CFrame.new(Core.Position, Vector3.new(Mouse.Hit.p.x, Core.Position.Y, Mouse.Hit.p.z)), UpdateSpeed / 2)
	else
		Hum.AutoRotate = true
	end
end)

Tool event:

--[[
	Custom Tool Event
]]

tool.Equipped:Connect(function()
	local player = game.Players.LocalPlayer
	local c = player.Character
	local equipped = false
	local anim = Instance.new("Animation")
	anim.AnimationId = "rbxassetid://" .. Hold
	local holdtrack = player.Character:WaitForChild("Humanoid", 1000):LoadAnimation(anim)
	holdtrack.Priority = Enum.AnimationPriority.Action
	while equipped == false do
		equipped = equipped.Value
		if equipped == true then
			holdtrack:Play()
		end
	end

	tool.Equipped:Connect(function()
		if equipped == true then
			equipped.Value = false
			if holdtrack then
				local tracks = player.Character:WaitForChild("Humanoid", 1000):GetPlayingAnimationTracks();
				for i, thistrack in pairs(tracks) do -- Stop and destroy all animations that are playing
					thistrack:Stop();
					thistrack:Destroy();
				end
			end
		end
	end)

	while equipped == true do
		equipped = equipped.Value
		if equipped == false then
			holdtrack:Stop()
		end
	end
end)

You update both the neck and the waist at UpdateSpeed/2 It should be UpdateSpeed

Wait, I don’t see the problem with the update speed. Please elaborate.

Maybe try both it was just a guess from me if anything is wrong with the UpdateSpeed it was just a guess but maybe try both to see if it did something:P I also just flew over the script.

I want everyone to pay attention to the second video and see why the arms are like that, unlike in the other videos.

It still has the same output. I also tried the script that you made for the tool.

Sorry then I cannot help you with that anymore, tried my best. It may also be a faulty roblox engine.

Well, it was nice of you to contribute.

1 Like

Hey, I found a very tedious fix. So if you used Roblox’s built in animation editor, apparently the current version is broken which is why your old animations are working. Use MoonAnimator and import all of your new, broken animations and export them through MoonAnimator. I use Motor6D for my arms to point at the camera direction and doing this fixed my Motor6D script. Make sure you check the animation priority in MoonAnimator.

Edit: If I had to take a guess, it looked like my animations created March 2022 onward had to be reimported using MoonAnimator.

2 Likes

Noted. I’m not going to use Moon Animator right now, but I might use it in the following days because I’m creating a new script for the torso following the mouse. I’ll tell you what I got out of it.

Using “Moon Animator 2” works. Thanks @Vestigen!

2 Likes

I’ve had this exact same problem happen, and I’m really curious for the fix for it.

I would rather not have to completely redo all my animations for a game if I could help it.

From the looks of it, it seems like now motor6Ds work differently. If you make one motor6D move, it no longer makes the rest that it is connected move with it?

(e.g., tilting the waist up no longer also tilts the head up, the head just compensates with the waist tilt.)

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.