Ive got a script that lets the player slide, i want to know when the players speed has decreased to less than the velocity it would have when walking and then stop the animation.
How could I do that?
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = script.Parent.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local Animator = Humanoid:WaitForChild("Animator")
local HumRootPart = Character:WaitForChild("HumanoidRootPart")
--99893655201485
local Animation = Instance.new("Animation")
Animation.AnimationId = "rbxassetid://137477863876911"
local Animation2 = Instance.new("Animation")
Animation2.AnimationId = "rbxassetid://99893655201485"
local SlideStartTrack = Animator:LoadAnimation(Animation)
local SlideContinuousTrack = Animator:LoadAnimation(Animation2)
UIS.InputBegan:Connect(function (input)
if input.KeyCode == Enum.KeyCode.C then
SlideStartTrack:Play()
SlideStartTrack:AdjustSpeed(3)
SlideStartTrack.Ended:Connect(function ()
SlideContinuousTrack:Play()
end)
local LinearVelocity = Instance.new("LinearVelocity")
LinearVelocity.Parent = HumRootPart
LinearVelocity.Attachment0 = HumRootPart.RootAttachment
LinearVelocity.MaxForce = 100000
LinearVelocity.VectorVelocity = HumRootPart.CFrame.LookVector * 100
LinearVelocity.Enabled = true
wait(0.5)
LinearVelocity:Destroy()
task.wait(0.1)
end
end)