I’m trying to make a dash system but its not working
https://gyazo.com/406009e1b00ee377f6c915f15eae7165
Server Script
ReplicatedStorage.ActionsRemotes.Dash.OnServerEvent:Connect(function(Plr)
local Char = game.Workspace[Plr.Name]
if CanDash and game.Workspace[Plr.Name].Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) then
warn("Dash")
CanDash = false
local Dash = Instance.new("BodyVelocity", Char.HumanoidRootPart)
Dash.Name = "Dash"
Dash.MaxForce = Vector3.new(1000000, 0, 1000000)
Dash.Velocity = Char.HumanoidRootPart.CFrame.LookVector * 100
wait(0.3)
Dash:Destroy()
wait(2)
CanDash = true
end
end)
Local Script
UserInputService.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.Space then
local HumanoidState = Char.Humanoid:GetState()
if HumanoidState == Enum.HumanoidStateType.Freefall then
ReplicatedStorage.ActionsRemotes.StartGliding:FireServer()
end
elseif Input.KeyCode == Enum.KeyCode.LeftShift then
Char.Humanoid.WalkSpeed = 32
RunAnimation:Play()
elseif Input.KeyCode == Enum.KeyCode.E then
ReplicatedStorage.ActionsRemotes.Dash:FireServer()
end
end)