This is my attempt using body velocity. in first person. It does dodge but not to the right, just a random direction.
01 | --Developed by Cluster studios, FDFXD |
02 | --Dodge Right using E, UT 2004 style |
03 |
04 | repeat wait() until game.Players.LocalPlayer.Character |
05 | player = game.Players.LocalPlayer.Character:WaitForChild( "Torso" ) |
06 |
07 | debounce = false |
08 |
09 | function DodgeRight() |
10 | if debounce = = false |
11 | then debounce = true |
12 | end |
13 | if script.Parent.Parent.powers.Mana.Value > 25 |
14 | then |
15 | script.Parent.Parent.powers.Mana.Value = script.Parent.Parent.powers.Mana.Value - 25 |
The problem is that you're having the player always dodge towards the positive X axis (which is independent of where the player is looking or what direction their character is facing).
You need to use CFrame.Angles(0, -math.pi/2, 0) * lookVector
(replacing lookVector with either the character's Torso's CFrame's lookVector, or else the lookVector of their camera) to get the velocity to use. (Also consider taking the 'y' component out of the lookVector and then re-normalizing it so that if their torso is angled sideways, they won't fly up/down at all). For dodging left, just take out the minus sign before the 'math.pi/2' part. (math.pi/2 is 90 degrees.)