Help with procedural animations

I’m trying to use procedural animation to create a combat system, for now I’m attempting to simply animate it before throwing it all into a full fledged system however I’m having trouble with the code below.

Essentially the arm moves to a weird initial keyframe behind the player rather than just moving on the joint. I’m unsure how I’d solve this.

Gif showing problem: https://gyazo.com/1bb5d73f92262b3ea54d781e1261acb2

( Don’t mind the way the arm faces backwards, it’s intentional to test )

   local TweenService = game:GetService("TweenService")

    game.Players.PlayerAdded:Connect(function(player)
    	player.CharacterAdded:Connect(function(Character)
    	
    		SwordProceduralM11(player, Character)
    	end)
    end)

    function SwordProceduralM11(Player, Character)
    	local CFrameValue = Instance.new("CFrameValue")
    	local SavedBaseCFrame = Character.Torso["Right Shoulder"].C0
    	
    	local Goal = {}
    	
    	CFrameValue.Changed:Connect(function()
    		Character.Torso["Right Shoulder"].C0 = CFrameValue.Value
    	end)
    	
    	wait(5)
    	local TweenSettings = TweenInfo.new(5, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0)
    	Goal.Value = SavedBaseCFrame * CFrame.Angles(math.rad(0), math.rad(0), math.rad(90))
    	local tween = TweenService:Create(CFrameValue, TweenSettings, Goal)
    	tween:Play()
    	
    end
1 Like

Initially the CFrame Value is CFrame.new() which is not the intended effect so do this:

    	local CFrameValue = Instance.new("CFrameValue")
    	local SavedBaseCFrame = Character.Torso["Right Shoulder"].C0
CFrameValue.Value = SavedBaseCFrame 

Thank you so much! I can’t tell you how long I’ve been trying to find a solution for this, do you think you could explain the logic behind this so I can have a better understanding of the purpose? Thanks!