So recently, I’ve been making a game. I tried to make a mid-air dash move for the player to use with body velocity which worked but not as much as I wanted it to due to the fact that the player couldn’t move freely as the force was being used. I found out about body Force and tried to use that instead but when I did use it, it didn’t make the player move. Here is my code:
local Character = script.Parent
local Humanoid = Character:WaitForChild(“Humanoid”)
local Root = Character:WaitForChild(“HumanoidRootPart”)
local CanDash = false
local OnGround = true
local CAS = game:GetService(“ContextActionService”)
Humanoid.StateChanged:Connect(function(old,new)
if new == Enum.HumanoidStateType.Freefall and OnGround == true then
if not CanDash then
CanDash = true
OnGround = false
end
elseif Humanoid.FloorMaterial ~= Enum.Material.Air then
CanDash = false
OnGround = true
end
end)
local function Dash()
if CanDash then
CanDash = false
local Force = Instance.new(“BodyForce”)
Force.Parent = Root
Force.Force = Root.CFrame.lookVector * 75
wait(0.5)
Force:Destroy()
end
end
CAS:BindAction(“Dash”, Dash, true, Enum.KeyCode.R)
I’m not sure why this isn’t working. Could you please tell me what I did wrong? I checked the Output and there were no errors.