this is the code i used. i am a noob at coding hence i used a guide to help me. The blue lined ones are my movedirection command. this is an dash code
local Userinputservice = game:GetService("UserInputService") local player = game.players.localplayer local animation = script:waitforchild('animation')
local key = Enum.keycode.F local velocity = 20000 local debounce = false local cooldown = 3 local duration = 0.10
local function dash() local character = player.character
if character and not debounce then
debounce = true
local humanoid = character.humanoid
local HRP = character.humanoidrootpart
local dashDirection = nil
local loaded animation = humanoid.movedirection
local lookvector = HRP.cframe.lookvector
local minusvelocity = -velocity
local isonground = humanoid.floormaterial ~= Enum.Material.Air and humanoid.floormaterial ~= Enum.Material.Water
if isonground then
if movedirection == Vector3.new(0,0,0) then
dashDirection = HRP.position + Vector3.new(lookvector.X, 0, lookvector.Z)
else
dashDirection = HRP.position + Vector3.new(moveDirection.X, 0, moveDirection.Z)
end
local bodygryo = Instance.new("BodyGyro")
bodygryo.Parent = HRP
bodygryo.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
bodygryo.D = 0
bodygryo.p = 500000
bodygryo.cframe = Vector3.lookat(HRP.position, dashDirection)
local attachment = Instance.new("attachment")
attachment.parent = HRP
local vectorforce = Instance.new("vectorforce")
vectorforce.parent = HRP
vectorforce.attachment0 = attachment
vectorforce.force = Vector3.new(0,0,minusvelocity)
LoadedAnimation:play()
humanoid.autorotate = false
wait(duration)
humanoid.autorotate = true
vectorforce:destroy()
bodygryo:Destroy()
attachment:destroy()
wait(duration * 2)
loadedanimation:stop()
end
end
wait(cooldown) end
Userinputservice.InputBegan:Connect(function(input) if input.KeyCode == key then dash() end end)
