I’m trying to make, for the first time, a four directional dash
But it’s not working like I wanted.
For some reason the dash works at front/back but not at left/right and the dash speed gets lower when touching the ground
I tried to find some solutions on internet, here on devforum (searching) and with ChatGPT, and nothing helped that much
Here’s the script:
game.ReplicatedStorage.Events.ClientEvents.Dash.OnServerEvent:Connect(function(plr)
local char = plr.Character
local dir = char.HumanoidRootPart.Velocity:Dot(char.HumanoidRootPart.CFrame.LookVector)
if dir > 0.9 then
local anim = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Normal.Dash.Front)
anim:Play()
local vectormove = Instance.new("VectorForce", char.HumanoidRootPart)
vectormove.Attachment0 = char.HumanoidRootPart.RootAttachment
vectormove.Force = Vector3.new(0,2000,-13000)
wait(0.1)
vectormove:Destroy()
elseif dir < 0.9 then
local anim = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Normal.Dash.Back)
anim:Play()
local vectormove = Instance.new("VectorForce", char.HumanoidRootPart)
vectormove.Attachment0 = char.HumanoidRootPart.RootAttachment
vectormove.Force = Vector3.new(0,2000,13000)
wait(0.1)
vectormove:Destroy()
else
dir = char.HumanoidRootPart.Velocity
dir = dir.Unit
if math.abs(dir.X) > math.abs(dir.Z) then
if dir.X > 0 then
local anim = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Normal.Dash.Right)
anim:Play()
local vectormove = Instance.new("VectorForce", char.HumanoidRootPart)
vectormove.Attachment0 = char.HumanoidRootPart.RootAttachment
vectormove.Force = Vector3.new(-13000,2000,0)
wait(0.1)
vectormove:Destroy()
else
local anim = char.Humanoid:LoadAnimation(game.ReplicatedStorage.Animations.Normal.Dash.Left)
anim:Play()
local vectormove = Instance.new("VectorForce", char.HumanoidRootPart)
vectormove.Attachment0 = char.HumanoidRootPart.RootAttachment
vectormove.Force = Vector3.new(13000,2000,0)
wait(0.1)
vectormove:Destroy()
end
end
end
end)