I’m working on a dash system for my RPG, and when I press the key to activate it, it just teleports me to that location in the workspace rather than move me farther away from my current position. Here’s the Vector area of my code.
local newVector3 = Vector3.new(0, 0, -25)
local newCFrame = CFrame.new(newVector3)
char.LowerTorso.CFrame = newCFrame
I would recommend using TweenService. An important notice is that no animation will be playing. If you want to make an animation for this, head over to the Animation page on the devforum.
local TweenService = game:GetService('TweenService')
local TweenInfo = TweenInfo.new(1) -- Creating a TweenInfo for our tween later. Usually, it's formatted like this: TweenInfo.new(time, EasingStyle, EasingDirection, count, repeat, delay).
local Character = Player.Character -- Our character variable
local HumanoidRootPart = Character.HumanoidRootPart
local newCFrame = HumanoidRootPart.CFrame * CFrame.new(0, 0, -25)
HumanoidRootPart.Anchored = true -- Stopping the character from moving.
local Tween = TweenService:Create(HumanoidRootPart, TweenInfo, {CFrame = newCFrame})
Tween:Play() -- Playing the dash
wait(1) -- Tweens don't put delay before executing commands, so make sure to have a wait snippet before the code that is supposed to play after the tween ends.
HumanoidRootPart.Anchored = false -- Making the character able to move again