Need help with dash system

Hi,
I have tried to make a dash system by using BodyVelocity but I have a problem at if it hit something (like player dash and hit part), the player will just got knocked away, so did there is the better way to do the dash system?

This is code in server side:

Remote = game.ReplicatedStorage.DashEvent

Remote.OnServerInvoke =   function(Player)
	if game.ReplicatedStorage.Stamina:FindFirstChild(Player.Name) then 
		if game.ReplicatedStorage.Stamina[Player.Name].Current.Value >= 30 and Player.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Swimming and Player.Character.Humanoid:GetState() ~= Enum.HumanoidStateType.Seated and Player.Character.Humanoid.MoveDirection ~= Vector3.new(0,0,0) then
			delay(0.1,function()
				local attachment = Instance.new("Attachment",Player.Character.HumanoidRootPart)
				local attachment1 = Instance.new("Attachment",Player.Character.Head)
				local t1= Instance.new("Trail")
				t1.Parent = Player.Character.HumanoidRootPart
				t1.Attachment0 = attachment
				t1.Attachment1 = attachment1
				t1.Lifetime = .5
			game.ReplicatedStorage.Stamina[Player.Name].Current.Value = game.ReplicatedStorage.Stamina[Player.Name].Current.Value - 30
	local BV = Instance.new("BodyVelocity", Player.Character.HumanoidRootPart)
	BV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
	BV.Velocity = Player.Character.Humanoid.MoveDirection*100 -- This is how fast you will go in the air
				game.Debris:AddItem(BV, 0.1)
				wait(.3)
				t1.Enabled =false
				wait(.4)
				game.Debris:AddItem(attachment,.1)
				game.Debris:AddItem(attachment1,.1)
				game.Debris:AddItem(t1,.1)
				 -- this one deletes the velocity so you stop flying up
	--[[
	local Clone = game.Lighting.DashEffect:Clone()
	Clone.Parent = workspace
	Clone.CFrame = Player.Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-1)
	i = Player.Character.Head.Orientation.Y 	
	Clone.Orientation = Vector3.new(90,i,0)
	]]
--	local Clone = game.Lighting.DashEffect2:Clone()
--	Clone.Parent = workspace
--	Clone.CFrame = Player.Character.HumanoidRootPart.CFrame*CFrame.new(0,0,-3)
--	i = Player.Character.Head.Orientation.Y
				--	Clone.Orientation = Vector3.new(90,i,0)
				end)
			return true
		else
			return nil
			end
		else return nil
	end
	end

Thanks and sorry for bad English.

2 Likes

Don’t set the MaxForce to math.huge, it some times causes fling. Instead set it to a high number such as 120000. If that doesn’t work I have some other ideas in mind.

1 Like

I have try it but i see the dashing speed is got decreased

1 Like

oh my god i thought this post meant a dashcam kind of system or a car crashing system (??)

im sorry

1 Like

Check out this post I made a while back about making an effective dash script/system:

local UIS = game:GetService('UserInputService')
local Player = game:GetService('Players').LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Root = Character:WaitForChild('HumanoidRootPart')

local Dash_Normal = 20 -- set the default range for better control if you want to change it later on
local Dash_Timeout = 0.15 -- how long will it wait in-between taps; think of this as tap speed
local Can_Dash = false -- can the player dash immediately? no.

function DashForward(root)
    local i = Instance.new('BodyPosition')
    i.MaxForce = Vector3.new(1000000,0,1000000) -- y-component is 0 because we don't want them to fly
    i.P = 100000
    i.D = 2000
    i.Position = (root.CFrame*CFrame.new(0,0,-Dash_Normal)).Position --get 20 units in front of the player
    i.Parent = root
    coroutine.wrap(function()
        wait(.2) --however long you want the dash to last
        i:Destroy() -- remove the BodyMover (important!!)
    end)()
end

UIS.InputBegan:Connect(function(input,istyping)
    if istyping then return end
    if input.KeyCode == Enum.KeyCode.W then
        if Can_Dash == true then
            Can_Dash = false
            DashForward(Root)
        else
            Can_Dash = true
            coroutine.wrap(function()
                wait(Dash_Timeout)
                Can_Dash = false
            end)()
        end
    end
end)
6 Likes

Thank you for your answer. my answer got solved.

2 Likes