Please help me i can't make slide dash script

this is my script

Actually, I know very well that my skills are insignificant. That is why help is more desperately needed. Please help me

-if i.KeyCode == Enum.KeyCode.LeftAlt and CanSlide then
		CanSlide = false

		local Slide = Instance.new("VectorForce")
		local A0 = Instance.new("Attachment", Char.HumanoidRootPart)
		--Slide.RelativeTo = "World"
		--Slide.Attachment0 = A0
		--Slide.Force = Char.HumanoidRootPart.CFrame.LookVector * Vector3.new(SlideForce, 0, SlideForce)
		local tweenInfo = TweenInfo.new(0.3, Enum.EasingStyle.Exponential, Enum.EasingDirection.InOut)
		local tween = game:GetService('TweenService'):Create(Slide.Force, tweenInfo, { FieldOfView = 2000})
		tween:Play()
		local T = Hum.Animator:LoadAnimation(SlideAnimation)
		T:Play()

		Slide.Parent = Char.HumanoidRootPart
		Slide.Enabled = true

		for _=1, 16 do
			wait(0.05)
			Slide.Force *= 1
		end

		Slide:Destroy()
		A0:Destroy()
		T:Stop()
		CanSlide = true
	end
  1. Added a TweenInfo for the sliding duration and modified the easing style and direction.
  2. Removed the for loop that multiplies the force by 1 repeatedly, as it doesn’t serve any purpose.

local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")

local CanSlide = true
local SlideForce = 50 -- Define your slide force value here
local SlideDuration = 0.8 -- Define your slide duration here

local function onKeyDown(i)
	if i.KeyCode == Enum.KeyCode.LeftAlt and CanSlide then
		CanSlide = false

		local Char = game.Players.LocalPlayer.Character
		local Hum = Char:FindFirstChild("Humanoid")
		local SlideAnimation = Instance.new("Animation") -- Create a new Animation object here or use a pre-defined one
		SlideAnimation.AnimationId = "rbxassetid://YOUR_ANIMATION_ID" -- Replace with your sliding animation asset ID

		local Slide = Instance.new("BodyVelocity", Char.HumanoidRootPart)
		Slide.MaxForce = Vector3.new(SlideForce, 0, SlideForce)
		Slide.Velocity = Char.HumanoidRootPart.CFrame.LookVector * Vector3.new(SlideForce, 0, SlideForce)

		local T = Hum:LoadAnimation(SlideAnimation)
		T:Play()

		local tweenInfo = TweenInfo.new(SlideDuration, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
		local tween = TweenService:Create(Slide, tweenInfo, {Velocity = Vector3.new(0, 0, 0)})
		tween:Play()
		tween.Completed:Wait()

		Slide:Destroy()
		T:Stop()
		CanSlide = true
	end
end

UserInputService.InputBegan:Connect(onKeyDown)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.