I want to make a script where you can press “q + w / a / s / d” to dash, and you’d dash to that key’s direction, here’s the script:
elseif input.KeyCode == Enum.KeyCode.Q and db == false then
db = true
for i, v in pairs(keysPressed) do
if v.KeyCode == Enum.KeyCode.W and not db1 then
db1 = true
moveDirection = moveDirection + Vector3.new(0, 1, -1)
char.HumanoidRootPart.Velocity = (camera.CFrame.lookVector + Vector3.new(0, 0.5, 0)) * 100
wait(1)
db1 = false
elseif v.KeyCode == Enum.KeyCode.S and not db1 then
db1 = true
moveDirection = moveDirection + Vector3.new(0, 1, 1)
char.HumanoidRootPart.Velocity = (camera.CFrame.lookVector + Vector3.new(0, -0.5, 0)) * -100
wait(1)
db1 = false
elseif v.KeyCode == Enum.KeyCode.D and not db1 then
db1 = true
moveDirection = moveDirection + Vector3.new(1, 1, 0)
char.HumanoidRootPart.Velocity = (camera.CFrame.rightVector + Vector3.new(0, 0.5, 0)) * 100
wait(1)
db1 = false
elseif v.KeyCode == Enum.KeyCode.A and not db1 then
db1 = true
moveDirection = moveDirection + Vector3.new(-1, 1, 0)
char.HumanoidRootPart.Velocity = (camera.CFrame.rightVector + Vector3.new(0, -0.5, 0)) * -100
wait(1)
db1 = false
end
end
db = false
end
My character dashes, but only in the air, in the ground he’s not moving. I’m new to body movers and stuff, I would really appreciate it if anyone could help!
https://gyazo.com/5bf9ab298dca54446672d5a22d1ff426
well, that’s not what I’m looking for, I want to create a dash
Yes I understand that. My apologies.
You’d want to handle changing the character’s move direction on the server, not the client. Have the client fire to the server whenever the Q key is pressed, and whenever it is released. Then, the server can do some sanity checks such as checking the debounce/cooldown, and then give the player the ability to dash temporarily.
okay, I’m gonna do that, but how do i fix the actual dash?
How would you want the dash to work? Would you want the player to be able to run faster as long as they are pressing down the Q key?
No I want the player’s body to be “pushed” to the direction of the key pressed
To make the player dash, you’d want to edit the velocity of the character’s primary-part (the HumanoidRootPart) to be the look vector of the primary-part multiplied by the ratio of the intended velocity to the current velocity.
function Dash(Character, Intensity)
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
if HumanoidRootPart then
HumanoidRootPart.Velocity = HumanoidRootPart.CFrame.LookVector * Intensity
end
end)
What you could do is to add this line
character.HumanoidRootPart.CFrame.lookVector * -5
When the proper key combinations are pressed. (The line i provided moves the player backwards so change it to your need)
but what about moving sideways?
Then change lookVector to rightVector (note that leftVector doesn’t exist so use rightVector with a negative value)
1 Like
ok so, it’s kinda working, but there are 2 problems, first if you don’t use shiftLock the directions get all messed up because I’m using HRP.CFrame.lookVector, and second the dash only works in the air, in the ground you can see it trying to move but it doesn’t
wait, imma use the camera look vector instead
okay it’s working now the problem i have is this:
https://gyazo.com/5bf9ab298dca54446672d5a22d1ff426
you see how at the end, when I don’t jump and try to dash nothing happens, do you know how to fix it?
It looks like the player is actually moving half-downwards into the baseplate when you dash, so offsetting it could work by using CFrame.Angles()
.
lookVector * CFrame.Angles(math.rad(30), 0, 0)
like that? I don’t know how to do it