#Dashing System Help

1 messages · Page 1 of 1 (latest)

golden hedge
#

Hello im tryna make my dash system more refinded the problem im having right now is that when i dash i want it to dash and not turn no other direction cause of the camera turning or nothing lemme use clips to explain

#

heres how my

#

dashing looks right now

#

like i want to make it so the dash always goes the right direction

#

its slightly unreliable

#
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local MovementRemote = ReplicatedStorage.Remotes.MovementHandler


local Character = script.Parent
local Player = Players:GetPlayerFromCharacter(Character)
local Humanoid = Character.Humanoid
local dashdebounce = false


UserInputService.InputBegan:Connect(function(input, gpe)
    if gpe then return end
    
    if input.KeyCode == Enum.KeyCode.Q then
        if UserInputService:IsKeyDown(Enum.KeyCode.W) then
            MovementRemote:FireServer("Dash", "Dash", "ForwardDash")
        elseif UserInputService:IsKeyDown(Enum.KeyCode.A) then
            MovementRemote:FireServer("Dash", "Dash", "LeftDash")
        elseif UserInputService:IsKeyDown(Enum.KeyCode.S) then
            MovementRemote:FireServer("Dash", "Dash", "BackDash")
        elseif UserInputService:IsKeyDown(Enum.KeyCode.D) then
            MovementRemote:FireServer("Dash", "Dash", "RightDash")
        else
            MovementRemote:FireServer("Dash", "Dash", "BackDash")
        end
        dashdebounce = true
        
        task.delay(0.4, function()
            dashdebounce = false
        end)
    end
    
end)



heres my local script

#

i dont have nitro so i cant send the module

#

💔

#
function DashHandler.Dash(character, dashTypeName)
    local humanoid = character.Humanoid
    local hrp = character.HumanoidRootPart
    if not humanoid or not hrp or humanoid.Health <= 0 then return end


    if activeDashes[humanoid] then return end
    if humanoid:GetAttribute("Stunned") or humanoid:GetAttribute("Attacking") or humanoid:GetAttribute("Blocking") then return end

    local animator = humanoid.Animator
    if not animator then return end

    local dashInfo = DashTypes[dashTypeName]
    if not dashInfo then
        warn("Invalid dash type:", dashTypeName)
        return
    end

    activeDashes[humanoid] = true 


    local dashJanitor = Janitor.new()

    humanoid:SetAttribute("Dashing", true)

    local runservicejanitor = Janitor.new()


    local attachment = Instance.new("Attachment", hrp)
    local linearVelocity = Instance.new("LinearVelocity", hrp)
    linearVelocity.MaxForce = 100000
    linearVelocity.Attachment0 = attachment
    linearVelocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
    linearVelocity.ForceLimitsEnabled = true
    linearVelocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
    linearVelocity.MaxAxesForce = Vector3.new(100000, 0, 100000)
    linearVelocity.VectorVelocity = dashInfo.GetVelocity(hrp.CFrame, dashInfo.Speed)


    local animTrack = animator:LoadAnimation(dashInfo.Animation)
    animTrack.Priority = Enum.AnimationPriority.Action 
    animTrack:Play()


    dashJanitor:Add(animTrack, "Stop")
    dashJanitor:Add(linearVelocity, "Destroy")
    dashJanitor:Add(attachment, "Destroy")
    dashJanitor:Add(function()
        if humanoid.Parent then
            humanoid:SetAttribute("Dashing", false)
        end

        task.delay(dashcd, function()
            if activeDashes[humanoid] == true then 
                activeDashes[humanoid] = nil
            end
        end)
    end)


    task.delay(dashduration, function()
        dashJanitor:Cleanup()
    end)
end
#

heres some part of the module