I have created a W,A,S,D double tap dashing system. One big problem is I'm not sure the best way to do this. Some have told me to do Char.HumanoidRootPart.Velocity and boost the player like that and some have said "Use body Velocity". At this point, I have used Velocity on parts (so no BodyVelocity). It works to a degree but I hope to make it smoother and better as I have seen better.
Currently how each looks like.
W: https://gyazo.com/a4a87de832911a90e864694c48aad88b As seen it is buggy, sometimes flinging you upwards and sometimes only moving a small distance.
A: https://gyazo.com/ca04894d382f42143c6c292b907afa04 Moving very little but if I jump i move further (this applies to all W a s d). This is because gravity
S: https://gyazo.com/9a55683bfd3c91f99120ac8b8472b9f0 S is pretty much broken, flinging you forward as you go back?
D: https://gyazo.com/c10a7c2d026696df3239336091bea291 D is similar to A where moves very little.
All of these use the same code but different variables and Velocity.
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local UIS = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EffectDictionary = require(ReplicatedStorage.ModuleScripts.EffectDictionary)
local Dashes = {
DashW = ReplicatedStorage.RemoteEvents.Other.DashW;
DashA = ReplicatedStorage.RemoteEvents.Other.DashA;
DashS = ReplicatedStorage.RemoteEvents.Other.DashS;
DashD = ReplicatedStorage.RemoteEvents.Other.DashD;
}
local DashDebounceW = true
local lastpressw
game:GetService("UserInputService").InputBegan:Connect(function(key,istyping)
if not istyping then
if key.KeyCode == Enum.KeyCode.W then
if lastpressw and tick() - lastpressw <= 0.5 and DashDebounceW then
DashDebounceW = false
local mouse = plr:GetMouse()
lastpressw = nil
Dashes.DashW:FireServer(mouse.Hit)
Char.HumanoidRootPart.Velocity = Char.HumanoidRootPart.Velocity + ((Char.HumanoidRootPart.CFrame * CFrame.Angles(math.rad(45), 0, 0)).lookVector * EffectDictionary.DashingMultiplier)
wait(0.5)
DashDebounceW = true
else
lastpressw = tick()
end
end
end
end)
Since Velocity is done here Char.HumanoidRootPart.Velocity = Char.HumanoidRootPart.Velocity + ((Char.HumanoidRootPart.CFrame * CFrame.Angles(math.rad(45), 0, 0)).lookVector * EffectDictionary.DashingMultiplier) There is no need for server script.
Since S is completely broken:
local plr = game.Players.LocalPlayer
local Char = plr.Character or plr.CharacterAdded:Wait()
local UIS = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EffectDictionary = require(ReplicatedStorage.ModuleScripts.EffectDictionary)
local Dashes = {
DashW = ReplicatedStorage.RemoteEvents.Other.DashW;
DashA = ReplicatedStorage.RemoteEvents.Other.DashA;
DashS = ReplicatedStorage.RemoteEvents.Other.DashS;
DashD = ReplicatedStorage.RemoteEvents.Other.DashD;
}
local DashDebounceS = true
local lastpresss
game:GetService("UserInputService").InputBegan:Connect(function(key,istyping)
if not istyping then
if key.KeyCode == Enum.KeyCode.S then
if lastpresss and tick() - lastpresss <= 0.5 and DashDebounceS then
DashDebounceS = false
local mouse = plr:GetMouse()
lastpresss = nil
Dashes.DashS:FireServer(mouse.Hit)
Char.HumanoidRootPart.Velocity = Char.HumanoidRootPart.Velocity + ((Char.HumanoidRootPart.CFrame * CFrame.Angles(math.rad(-45), 0, 0)).lookVector * -EffectDictionary.DashingMultiplier)
wait(0.5)
DashDebounceS = true
else
lastpresss = tick()
end
end
end
end)
Same code but different line for velocity and different variables.
I hope someone would assist me on making this better (I care about efficiency as well). Thank you in advance. Hopefully this will get fixed.
