Dash System not working

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)

You can make a dash script without having to launch an event
“LocalScript In StarterCharacterScript”

local player = game.Players.LocalPlayer
local Char = player.Character
local UserInputService = game:GetService("UserInputService")

local debounce = true

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.E and debounce then
		debounce = false
		Char.HumanoidRootPart.Velocity = Char.HumanoidRootPart.CFrame.lookVector * 140
		wait(1.5) -- cooldown
		debounce = true
	end
end)
1 Like