Ok so i want to click lets say R button on the keyboard and then player moves forward slowly
like this https://gyazo.com/f7f6bfef5a6fe329116befe4556fa7cf
Right now
https://gyazo.com/41bfd611c169c20e8c54168bc1adf427
i just used animation but camera stays in place and player comes back after its finished.
help :)
In the example you used its obvious that you tried to use the character animations, I will tell you this now, this will NEVER work, animations will only move character parts/joints never the HumanoidRootPart (Which is where the camera is centered on). You can fix all this by using a body velocity. (Also make sure to have the animation not move the character or else it will do both movements at the same time). Makes sure this is all a local script.
01 | local player = game:GetService( "Players" ).LocalPlayer |
02 | local Character = player.Character or player.CharacterAdded:Wait() |
03 | local RootPart = Character.HumanoidRootPart |
04 | -- if you already have the variables above in your own script there is no need to write them again |
05 |
06 | --instead of using animations we will use a bodyvelocity, it is basically speed in a given direction |
07 |
08 | local BV = Instance.new( "BodyVelocity" ) |
09 | BV.MaxForce = Vector 3. new( math.huge , math.huge , math.huge ) |
10 | --in order to make the character actually move, we will give them speed in the direction they are facing |
11 | BV.Velocity = RootPart.CFrame.lookVector.Unit * 50 -- you can change this if its too fast or too slow |
12 | --make sure it is parented to the "HumanoidRootPart" if it's not the script won't work. |
13 | BV.Parent = RootPart |
14 | wait( 2 ) -- or however long you want the speed to last |
15 | BV:Destroy() |
I hope this fixed your problem and please mark this as the answer if so! :)