I'm trying to make a dodge which suspends you in the air while also moving you in one direction, i have achieved that by using tweenservice and CFrame, the only problem is whenever I run this code it turns my player in a fixed rotation, right now my player moves right but my character is looking forward. this is my code
01 | game.ReplicatedStorage.Dodge.OnServerEvent:Connect( function (player) |
02 | local tweenService = game:GetService( "TweenService" ) |
03 | local part = player.Character.HumanoidRootPart |
04 |
05 | game.Workspace.DodgeCircle.Transparency = 0 |
06 | player.Character.HumanoidRootPart.Anchored = true |
07 | local goal = { } |
08 | goal.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position + Vector 3. new( 25 , 0 , 0 )) |
09 | local tweenInfo = TweenInfo.new(. 2 ) |
10 | local tween = tweenService:Create(part, tweenInfo, goal) |
11 | tween:Play() |
12 |
13 | wait(. 2 ) |
14 | game.Workspace.DodgeCircle.Transparency = 1 |
15 | player.Character.HumanoidRootPart.Anchored = false |
16 | end ) |
I Fixed this by adding CFrame.Angles into my script the final script looks something like this
01 | game.ReplicatedStorage.Dodge.OnServerEvent:Connect( function (player) |
02 | local tweenService = game:GetService( "TweenService" ) |
03 | local part = player.Character.HumanoidRootPart |
04 |
05 | game.Workspace.DodgeCircle.Transparency = 0 |
06 | player.Character.HumanoidRootPart.Anchored = true |
07 | local goal = { } |
08 | goal.CFrame = CFrame.new(player.Character.HumanoidRootPart.Position + Vector 3. new( 25 , 0 , 0 )) * CFrame.Angles( 0 , - 1.5 , 0 ) |
09 | local tweenInfo = TweenInfo.new(. 2 ) |
10 | local tween = tweenService:Create(part, tweenInfo, goal) |
11 | tween:Play() |
12 |
13 | wait(. 2 ) |
14 | game.Workspace.DodgeCircle.Transparency = 1 |
15 | player.Character.HumanoidRootPart.Anchored = false |
16 | end ) |