Hey everyone! I just started working with lerp, CFrame and all that and I’m using it to animate tools, which I know isn’t necessary but I just want to expand my knowledge further, nevertheless, I came up with this script that animates the Motor6D of the player’s arms, however, I haven’t been able to figure out how to reset them back to the original position. I’ve tried storing the original positions and then making them that when the tool is unequipped but that didn’t work. Any help would be fantastic, and I hope you have an amazing day! ![]()
local tool = script.Parent
local original_LSC0
local original_RSC0
function equipanim()
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
if player then
local character = player.Character
if character then
local LS = character.Torso["Left Shoulder"]
local RS = character.Torso["Right Shoulder"]
local targetRSC0 = RS.C0 * CFrame.Angles(math.rad(0), math.rad(0), math.rad(40.012))
local targetLSC0 = LS.C0 * CFrame.Angles(math.rad(0), math.rad(0), math.rad(-40.012))
original_LSC0 = LS.C0
original_RSC0 = RS.C0
local time = 1
local step = 0.01
for i = 0, 1, step do
RS.C0 = RS.C0:lerp(targetRSC0, i)
LS.C0 = LS.C0:lerp(targetLSC0, i)
wait(time * step)
end
RS.C0 = targetRSC0
LS.C0 = targetLSC0
end
end
end
function unequipanim()
if original_LSC0 and original_RSC0 then
local player = game.Players:GetPlayerFromCharacter(tool.Parent)
if player then
local character = player.Character
if character then
local LS = character.Torso["Left Shoulder"]
local RS = character.Torso["Right Shoulder"]
LS.C0 = original_LSC0
RS.C0 = original_RSC0
end
end
end
end
tool.Equipped:Connect(equipanim)
tool.Unequipped:Connect(unequipanim)