Ill make it simple: I want to make the character play a certain walking animation when going forward and another when going backwards, this is what i've tried so far:
1 | local Player = game:GetService( "Players" ).LocalPlayer |
2 | local Character = Player.Character |
3 | local Humanoid = Character.Humanoid |
4 | local Camera = workspace.CurrentCamera |
5 | local Result = Camera.CFrame:VectorToObjectSpace(Humanoid.MoveDirection) |
6 | while true do |
7 | wait( 1 ) |
8 | print (Result) --This prints 0,0,0 every 1 second- Doesnt work. |
9 | end |
Anything that helps me reach my goal would be appreciated, thanks.
I would change the defaut walk animation everytime you press S (or your custom key).
01 | local UIS = game:GetService( "UserInputService" ) |
02 | local animateScript = character:WaitForChild( "Animate" ) |
03 |
04 | -- Change the defaut walk animation: |
05 | animateScript.walk.WalkAnim.AnimationId = "rbxassetid://CustomAnimationForwards" |
06 |
07 | -- Walk Backwards animation when pressing S: |
08 | UIS.InputBegan:Connect( function (key) |
09 | if key.KeyCode = = Enum.KeyCode.S then |
10 | animateScript.walk.WalkAnim.AnimationId = "rbxassetid://CustomAnimationBackWards" |
11 | end |
12 | end |
13 | end ) |
14 |
15 | -- Reset Forward animation when release S: |