so i have a bodyvelocity that constantly moves the player in the direction theyre looking
but i dont know how to also tween it or something of the sort to make it slowly decrease in speed
is there a way to tween a variable or the speed of the velocity while keeping the direction ?
local Decrease = 0.1
local VelSpeed = 2.5
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Char)
task.wait(5)
local Root:Part = Char:WaitForChild("HumanoidRootPart")
local X,Z = 1, 1
local Vel = Instance.new("BodyVelocity")
Vel.MaxForce = Vector3.new(1e5, 1e5, 1e5)
Vel.Parent = Root
Vel.P = 1e4
Player.Chatted:Connect(function(Str)
X = tonumber(Str)
Z = tonumber(Str)
end)
task.spawn(function()
while true and task.wait() do
local Dir = Root.CFrame.LookVector*VelSpeed
X = math.max(X-Decrease, 1)
Z = math.max(Z-Decrease, 1)
Vel.Velocity = Vector3.new(Dir.X*X, Dir.Y, Dir.Z*Z)
end
end)
end)
end)