VectorForce distance traveled is COMPLETELY broken

I’ve got my dash right where I want it, however, when I dash from the Air, it flies drastically far. I even tried stopping it from dashing in the Air entirely, but that doesn’t work, even after I tried to make it stop while jumping.

I have no idea how to fix this, and have tried multiple solutions, even detecting the change in the Y axis.

Snippet of my code:

if Char.Humanoid.FloorMaterial ~= Enum.Material.Air and Char.Humanoid:GetState() ~= Enum.HumanoidStateType.Jumping then
		print(Char.Humanoid:GetState())
		Char.Humanoid.JumpHeight = 0
		
	-- Calculating Dash length from Strength & Speed --
	local Speed = PlayerData.PlayerDataStore[UserID].Stat["Speed"]
	local Strength = PlayerData.PlayerDataStore[UserID].Stat["Strength"]

	local Cooldown = 3 - (Speed*0.01)
	local DashLength = .5
	local DashSpeed = 30 + (Strength*.6)

	if PlayerData.PlayerDataStore[UserID].Status["CombatStatus"] == "None" then
		-- Making sure CombatStatus is none before dashing	

		-- Back Dash
		if Movement == "ForwardsDash" and PlayerData.PlayerDataStore[UserID].Cooldown["OnCooldownFront"] == false then

			PlayerData.PlayerDataStore[UserID].Cooldown["OnCooldownFront"] = true
			PlayerData.PlayerDataStore[UserID].Status["CombatStatus"] = "Dashing"
			CombatModule:StaminaRegenOff(Player)

			-- Stamina Drain --

			PlayerData.PlayerDataStore[UserID].Stat["Stamina"] = PlayerData.PlayerDataStore[UserID].Stat["Stamina"]-5
			
			-- Creating an attachment, or finding it if it's already created
			local Attachment = Char.HumanoidRootPart:FindFirstChildWhichIsA("Attachment")
			if not Attachment then
				Attachment = Instance.new("Attachment")
				Attachment.Parent = Char.HumanoidRootPart
				Attachment.WorldPosition = Char.HumanoidRootPart.Position
				Attachment.Orientation = Char.HumanoidRootPart.Orientation
			end
				
				-- Setting up Dash w/ VectorForce -- 
				
				local Dash = Instance.new("VectorForce")
				Char.Humanoid:ChangeState(Enum.HumanoidStateType.Physics)
				Dash.Parent = Char.HumanoidRootPart
				Dash.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
				Dash.Attachment0 = Attachment
				Dash.ApplyAtCenterOfMass = true
				Dash.Force = Vector3.new(0,0,-16500)
				Dash.Enabled = true

1 Like

So it flies farther in the air because of friction; you have none when airborne, essentially.
As for detecting when you’re in the air just hold a value that changes whenever the humanoid changes to the Jumping, FreeFalling, and Landed states.

1 Like