#how to properly make a dash system (as in strongest battlegrounds, etc.)

1 messages · Page 1 of 1 (latest)

fathom crown
#
local DASHUSED={}

local DASHDB={}

local TimeTillReset=1.5

local DASHCD=0.5

local DASHCFRAMES={
    [1]=CFrame.new(-1,-1,-20),
    [2]=CFrame.new(-1,-1,20),
    [3]=CFrame.new(-20,-1,-1),
    [4]=CFrame.new(20,-1,-1),
}

game.ReplicatedStorage.Remotes.Dash.OnServerEvent:Connect(function(player, message, number)
    
    if DASHDB[player] then return end
    
    DASHDB[player]=true
    
    if DASHUSED[player]==nil then
        
        DASHUSED[player]={}
        
    end
    
    if not DASHUSED[player][number] and #DASHUSED[player]<2 then

        table.insert(DASHUSED[player], number, message)

    elseif #DASHUSED[player]==2 then

        task.wait(TimeTillReset)

        table.clear(DASHUSED[player])

    end
    
    local HRP=player.Character:WaitForChild("HumanoidRootPart")
    
    if HRP then
        
        local LV=Instance.new("LinearVelocity",HRP)
        local Attachment=Instance.new("Attachment", HRP)
        
        local CFrameCalculated
        if message=="FrontDash" then
            CFrameCalculated=HRP.CFrame * DASHCFRAMES[1]
        elseif message=="BackDash" then
            CFrameCalculated=HRP.CFrame * DASHCFRAMES[2]
        elseif message=="LeftDash" then
            CFrameCalculated=HRP.CFrame * DASHCFRAMES[3]
        elseif message=="RightDash" then
            CFrameCalculated=HRP.CFrame * DASHCFRAMES[4]
        end
        LV.MaxForce=math.huge
        LV.VectorVelocity=(Vector3.new(CFrameCalculated) - HRP.Position).Unit * Vector3.new(100,0,100)
        LV.Attachment0=Attachment
        
        game.Debris:AddItem(LV,0.1)
        game.Debris:AddItem(Attachment,0.1)
        
        task.wait(DASHCD)
        
        DASHDB[player]=false
    end
    
end)```
#

everything works but when i do the actual dash, it just sends me back and forth and everywhere

#

(don't mind my avatar i just thought of making it look stupid)

#

i can see that lookvectors for a sec but then it disappears

gray mist
#

Mb I wasnt verified

fathom crown
#

i just did this

#

HRP.Position=DashPosition

#

still getting tp'd to random positions

gray mist
fathom crown
#
local DASHUSED={}

local DASHDB={}

local TimeTillReset=1.5

local DASHCD=0.5

game.ReplicatedStorage.Remotes.Dash.OnServerEvent:Connect(function(player, message, number)
    
    if DASHDB[player] then return end
    
    DASHDB[player]=true
    
    if DASHUSED[player]==nil then
        
        DASHUSED[player]={}
        
    end
    
    if not DASHUSED[player][number] and #DASHUSED[player]<2 then

        table.insert(DASHUSED[player], number, message)

    elseif #DASHUSED[player]==2 then

        task.wait(TimeTillReset)

        table.clear(DASHUSED[player])

    end
    
    local HRP=player.Character:WaitForChild("HumanoidRootPart")
    
    if HRP then
        
        local DashPosition
        
        local LV=Instance.new("LinearVelocity", HRP)
        LV.MaxForce=math.huge
        
        local Attachment=Instance.new("Attachment",HRP)
        
        if message=="FrontDash" then
            DashPosition=(HRP.CFrame.LookVector * 25)
        elseif message=="BackDash" then
            DashPosition=(HRP.CFrame.LookVector * -25)
        elseif message=="LeftDash" then
            DashPosition=(HRP.CFrame.RightVector * -25)
        elseif message=="RightDash" then
            DashPosition=(HRP.CFrame.LookVector * 25)
        end
        
        LV.VectorVelocity=DashPosition
        
        LV.Attachment0=Attachment

        game.Debris:AddItem(LV,0.1)
        
        task.wait(DASHCD)
        
        DASHDB[player]=false
    end
    
end)```
#

i changed the code a little bit but gives same results

tacit inlet
#

Alright so

#

At first, your problem was that you just teleported them to the dash position, without having used a body velocity or something to propel the player forward

#

Now I'd just suggest

#

lowering the maxforce a bit

#

so it doesn't teleport you, you know?

fathom crown
#

i don't rlly tp no more it just goes in random directions

tacit inlet
#

Alright so

#

my suggestions are

#

lowering the max force

#

to 50,50,50

#

or 100,100,100

#

since it moves in multiple directions

#

that way it can move smoothly but surely

tacit inlet
#

I'm pretty sure your math is a bit wrong

#

anyway, you should probably switch to using a "BodyVelocity" instead

#

I would say it's easier to work with

#

especially for systems such as this

fathom crown
#

didnt realize this but it used lookvector for right dash

#

fixed it

#
local DASHUSED={}

local DASHDB={}

local DASHCD=3

game.ReplicatedStorage.Remotes.Dash.OnServerEvent:Connect(function(player, message, number)
    if DASHDB[player] then return end
    DASHDB[player]=true
    if DASHUSED[player]==nil then
        DASHUSED[player]={}
    end
    if not DASHUSED[player][number] and #DASHUSED[player]<2 then
        table.insert(DASHUSED[player], number, message)
    elseif #DASHUSED[player]==2 then
        task.wait(DASHCD)
        table.clear(DASHUSED[player])
    end
    local HRP=player.Character:WaitForChild("HumanoidRootPart")
    if HRP then
        local DashPosition
        local BV=Instance.new("BodyVelocity", HRP)
        BV.MaxForce=Vector3.new(100,0,100)
        if message=="FrontDash" then
            DashPosition=(HRP.CFrame.LookVector * 25)
        elseif message=="BackDash" then
            DashPosition=(HRP.CFrame.LookVector * -25)
        elseif message=="LeftDash" then
            DashPosition=(HRP.CFrame.RightVector * -25)
        elseif message=="RightDash" then
            DashPosition=(HRP.CFrame.RightVector * 25)
        end
        BV.Velocity=DashPosition
        game.Debris:AddItem(BV,0.5)
        task.wait(DASHCD)
        DASHDB[player]=false
    end
end)
#

now it just doesn't move me

fluid hearth
#

alr

fathom crown
#

only moved me when i changed maxforce to math.huge

#

💔

#

also its fixed now just gotta uh

#

change debris time

fluid hearth
#

So the deal with BodyVelocity is that it can only be applied to parts that have no NetworkOwner or it is applied by the NetworkOwner themselves

fluid hearth
fathom crown
#
local DASHUSED={}

local DASHDB={}

local DASHCD=3

game.ReplicatedStorage.Remotes.Dash.OnServerEvent:Connect(function(player, message, number)
    if DASHDB[player] then return end
    DASHDB[player]=true
    if DASHUSED[player]==nil then
        DASHUSED[player]={}
    end
    if not DASHUSED[player][number] and #DASHUSED[player]<2 then
        table.insert(DASHUSED[player], number, message)
    elseif #DASHUSED[player]==2 then
        task.wait(DASHCD)
        table.clear(DASHUSED[player])
    end
    local HRP=player.Character:WaitForChild("HumanoidRootPart")
    if HRP then
        local DashPosition
        local BV=Instance.new("BodyVelocity", HRP)
        BV.MaxForce=Vector3.new(math.huge,0,math.huge)
        if message=="FrontDash" then
            DashPosition=(HRP.CFrame.LookVector * 50)
        elseif message=="BackDash" then
            DashPosition=(HRP.CFrame.LookVector * -50)
        elseif message=="LeftDash" then
            DashPosition=(HRP.CFrame.RightVector * -50)
        elseif message=="RightDash" then
            DashPosition=(HRP.CFrame.RightVector * 50)
        end
        BV.Velocity=DashPosition
        game.Debris:AddItem(BV,0.4)
        task.wait(DASHCD)
        DASHDB[player]=false
    end
end)```
fluid hearth
#

ah nvm i was talking nonsene if it is a instance then it should work on the server as well

#

mb

fathom crown
#

i have another favor, how do i make the separate dash come back

#

like lets say

#

i used front dash

#

2 seconds ago

#

and i just used side dash

#

how do i make them come back separately in like 3 seconds

#

ok wait im sparkin an idea in my head

tardy falconBOT
#

studio** You are now Level 13! **studio

fluid hearth
#

what exactly do you mean by "come back"

fluid hearth
fathom crown
#

nvm i think im on the right track but just cant thnk of it

fathom crown
#

means you can use it again

#

cd happens

#

you can use it again

#

in tsb, you can usually do a side dash right after a front dash

#

just making it clearer

fluid hearth
#

Ah like tsb....

#

this kinda gives me a flash back of certain fella anyways

#

Just separte the dash systems

#

so one dash system for side dashes only and one for front and back dashes

fathom crown
#

ok i think this one does it but its both dashes 💔

#

and im pretty sure it just resets the task.wait

fluid hearth
fathom crown
#

i just did this and pray it works

#

im going toremove storeddashes i think its useless now

fluid hearth
#

so what exactly did this do now?
aren't you trying to change he DASHCD or what am i missing

#

it feels like im misunderstanding something

fathom crown
#

ok so i got another problem woohoo i hate problems

#
local PLRS=game:GetService("Players")
local RS=game:GetService("ReplicatedStorage")
local UIS=game:GetService("UserInputService")
local Remotes=RS:WaitForChild("Remotes")
local Dash=Remotes:WaitForChild("Dash")

local player=PLRS.LocalPlayer

local char=player.Character

local hum=char:WaitForChild("Humanoid")

UIS.InputBegan:Connect(function(input, GPE)
    if UIS:IsKeyDown(Enum.KeyCode.W) or hum.MoveDirection.Magnitude==0 and UIS:IsKeyDown(Enum.KeyCode.Q) then
        Dash:FireServer("FrontDash", 1)
    elseif UIS:IsKeyDown(Enum.KeyCode.S) and UIS:IsKeyDown(Enum.KeyCode.Q) then
        Dash:FireServer("BackDash", 1)
    elseif UIS:IsKeyDown(Enum.KeyCode.A) and UIS:IsKeyDown(Enum.KeyCode.Q) then
        Dash:FireServer("LeftDash", 2)
    elseif UIS:IsKeyDown(Enum.KeyCode.D) and UIS:IsKeyDown(Enum.KeyCode.Q) then
        Dash:FireServer("RightDash", 2)
    end
end)
#

i press W or A or S or D and it just dashes

#

didnt even press Q

fluid hearth
#

you need to do if UIS:IsKeyDown(Enum.KeyCode.W) and UIS:IsKeyDown(Enum.KeyCode.Q) or hum.MoveDirection.Magnitude==0 and UIS:IsKeyDown(Enum.KeyCode.Q) then

fathom crown
#

ok nvm i LIED its just the W key

fluid hearth
#

💔

fluid hearth
#

all gud

fathom crown
#

i saw a youtuber do that and it worked for them so idk unless i was tweaking

fluid hearth
#

well did it fix it?

fathom crown
#

yeah but still have a problem with dash cd

#

lets say i did forward dash a second ago and now i just did left dash

#

in seconds it would be like

#

FD:1
LD:0
FD:2
LD:1
so on

#

and then when the dashes reach 3

#

it resets

#

to make it useable

fluid hearth
#

i see

#

but isn't the easiest way just to separate the dashes into to different scripts

#

so they don't share a cooldown or you don't have to make more if statements

fathom crown
#

ill just do the different scripts then

fluid hearth
#

i mean we can try to make it work in one script you decide

fathom crown
#

ok yk what ill just try to do it in one script since most things require one script

fluid hearth
#

alr

#

then i think its best to try to make each dash type a function and create a 2nd DASHCD which is only for Left and Right Dashes

#

with dash types i mean front/back dashes and righ/left dashes

fathom crown
#

ok i think i found the problem

#

it was bc i did DASHUSED[player][message] instead of DASHUSED[player][number]

#

nvm