Dash Script Help

Hello everyone! Hope you are having a great day.

I recently made a simple dash script, using AssemblyLinearVelocity. The only problem with it, however, is that when you are on the ground, it only sends you a fraction of speed and length as it does when you jump/are in the air. Is there a way to account for this. I am open to the possibility of using something else than AssemblyLinearVelocity, unless it isn’t needed. The code is provided below.

local UserInputService = game:GetService("UserInputService")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

local coolDown = 3
local debounce = false

UserInputService.InputBegan:Connect(function(key, gameProcessed)
	if gameProcessed then return end
	
	if debounce then return end
	
	debounce = true
	
	if key.KeyCode == Enum.KeyCode.Q then
		character.HumanoidRootPart.AssemblyLinearVelocity = character.HumanoidRootPart.CFrame.LookVector * 100
		task.wait(coolDown)
		debounce = false
	end
end)
1 Like

Any help would be appreciated (subtle bump)

1 Like

Reconsider using a BodyVelocity or LinearVelocity instance.
It is known that BodyVelocity is deprecated and LinearVelocity is supposed to be used for future work, but I do recommend BodyVelocity since it is more easier to learn with.

Below, I’ve fixed some mistakes in your code, and used BodyVelocity. Oh yeah, you don’t have to use AssemblyLinearVelocity for this.

local UserInputService = game:GetService("UserInputService")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootpart = character:WaitForChild("HumanoidRootPart")

local debris = game:GetService("Debris")

local coolDown = 3
local debounce = false

UserInputService.InputBegan:Connect(function(key, gameProcessed)
	if gameProcessed then return end

	if key.KeyCode == Enum.KeyCode.Q and debounce ~= true then
		debounce = true

		local bv = Instance.new("BodyVelocity", rootpart)
		bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
		bv.Velocity = rootpart.CFrame.LookVector * 50

		debris:AddItem(bv, 0.2)

		task.wait(coolDown)
		debounce = false
	end
end)

The code above is supposed to be used in a LocalScript, it can be stored either in StarterPlayer > StarterCharacterScripts or StarterPlayerScripts.

Please let me know if I haven’t explained anything well.

Hey, thankyou so much, but is there any way to make it faster, but with the same distance?

Could you elaborate on what you mean by “same distance”?

I mean the same length of which the player gets boosted, and by faster I mean get to the end point at a faster speed.

1 Like
		bv.Velocity = rootpart.CFrame.LookVector * 50

if u change the 50 to a different number it should change the speed

Well, I added two variables called wtime and speed, so you can change how much time it takes for the velocity to end, and how fast the velocity is going to be

local UserInputService = game:GetService("UserInputService")

local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local rootpart = character:WaitForChild("HumanoidRootPart")

local debris = game:GetService("Debris")
local wtime = 0.1
local speed = 40

local coolDown = 3
local debounce = false

UserInputService.InputBegan:Connect(function(key, gameProcessed)
	if gameProcessed then return end

	if key.KeyCode == Enum.KeyCode.Q and debounce ~= true then
		debounce = true

		local bv = Instance.new("BodyVelocity", rootpart)
		bv.MaxForce = Vector3.new(math.huge,0,math.huge)
		bv.Velocity = rootpart.CFrame.LookVector * speed

		debris:AddItem(bv, wtime)

		task.wait(coolDown)
		debounce = false
	end
end)
1 Like

Sorry, this is a weird question, but is there a way to make this have friction. I ask this because I want to implement this with a sliding component as well.

Would appreciate any help fffffffff

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