I am trying to create a dash script:

uis.InputBegan:Connect(function(key)
	--<<Right Dash>>--
	if key.KeyCode == Enum.KeyCode.E then
		local OldV
		---
		HumanRoot.Velocity = HumanRoot.CFrame.XVector*130
		---

		local TweenService = game:GetService("TweenService")
		---
		TweenService:Create(HumanRoot, TweenInfo.new(0.4, Enum.EasingStyle.Linear, 		Enum.EasingDirection.Out), {Velocity = OldV}):Play()
	end
end)

but I don't know how to get the old velocity without getting the current velocity. How could I get the velocity and keep the value of the variable the same as the old velocity value.

2 comments

0

Store it in a variable outside of your function and update it each you call the function in the end.

0

thanks it works how it should