How To Blend In Lua-Scripted Animations

Have you ever used some sort of CFrame manipulation and had some animation break it? Well let me introduce you to a Motor6D property called .Transform.


What is Motor6D and .Transform?

Motor6D

Motor6D's are the objects that make animations possible in the first place! They connect objects together and also allow it to be manipulated by Animations.

.Transform

.Transform is the internal CFrame of the Motor6D that is manipulated by Animations. Do note that this property is scriptable only, it doesn’t pop up in the Properties widget.


How do I use .Transform?

Well you can use RunService.Stepped (because it runs after the Humanoid has loaded) to overwrite .Transform and practically stop animations from running in that particular body part. For the examples, I will be overriding the left and right arm.

R6

local RNS = game:GetService("RunService")
local PS = game:GetService("Players")

local player = PS.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local torso = char:WaitForChild("Torso")
local rShoulder, lShoulder = torso:WaitForChild("Right Shoulder"), torso:WaitForChild("Left Shoulder")

RNS.Stepped:Connect(function()
	if char then
		rShoulder.Transform = CFrame.new()
		lShoulder.Transform = CFrame.new()
	end
end)

R15

local RNS = game:GetService("RunService")
local PS = game:GetService("Players")

local player = PS.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local rShoulder, rElbow, rHand = char.RightUpperArm:WaitForChild("RightShoulder"),  char.RightLowerArm:WaitForChild("RightElbow"), char.RightHand:WaitForChild("RightWrist")
local lShoulder, lElbow, lHand = char.LeftUpperArm:WaitForChild("LeftShoulder"), char.LeftLowerArm:WaitForChild("LeftElbow"), char.LeftHand:WaitForChild("LeftWrist")

RNS.Stepped:Connect(function()
	if char then
		rShoulder.Transform = CFrame.new()
		rElbow.Transform = CFrame.new()
		rHand.Transform = CFrame.new()
		lShoulder.Transform = CFrame.new()
		lElbow.Transform = CFrame.new()
		lHand.Transform = CFrame.new()
	end
end)
10 Likes

This could be useful for procedural animations, like opening a vault door that uses IK to hold it. :+1:

1 Like