I'm trying to make a character dash on double-press (W, A, S, D). I'm using BodyVelocity inside HumanoidRootPart to dash.
W Dash is pretty straight-forward, just take the lookVector, multiply by some speed and set bodyVelocity.Velocity to that. S Dash is almost the same, just multiply the lookVector by -1.
Side dash is the problem though. I tried multiplying by CFrame.Angles, adding some vectors but couldn't make it work, here's the simplified version of my code:
local dashRemote = game:GetService("ReplicatedStorage"):WaitForChild("Remotes").Dash
local speed = 100
local timeNeeded = 0.25
local dirs = {
['a'] = CFrame.Angles(-90, 0, 0),
['d'] = CFrame.Angles(90, 0, 0),
['w'] = 1,
['s'] = -1,
}
dashRemote.OnServerEvent:Connect(function(plr, key)
local root = plr.Character.HumanoidRootPart
local direction = dirs[string.char(key):lower()]
local velocity = Instance.new("BodyVelocity", root)
velocity.MaxForce = Vector3.new(1, 1, 1) * math.huge
velocity.Velocity = root.CFrame.lookVector * direction * speed
delay(timeNeeded, function() velocity:Destroy() end)
end)
Any kind of help is appreciated, Thanks.

2 comments
Why you using string.char? just use string.lower(key)
Because that key is an integer (I got it from KeyCode.Value), so to turn integer into character I'm using string.char