Dashing problem

My dash system has a problem with dashing the wrong way. Whenever I activate the dash, only when I look at a specific direction will the dash go the right direction. In most cases… it goes the wrong way. How can I fix this?

uis.InputBegan:Connect(function(input, gpe)
	if not gpe then
		if input.KeyCode == Enum.KeyCode.Q then
			local linearVelocity = Instance.new("LinearVelocity")
			linearVelocity.Attachment0 = hrp.RootAttachment
			linearVelocity.MaxForce = 100000
			linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
			
			if hum.MoveDirection ~= Vector3.new(0, 0, 0) then
				linearVelocity.VectorVelocity = hum.MoveDirection * 100
			else
				linearVelocity.VectorVelocity = hrp.CFrame.LookVector * 100
			end
			
			linearVelocity.Parent = hrp
			task.wait(0.1)
			linearVelocity:Destroy()
		end
	end
end)

does the weird dashing directions happen when youre moving, or not moving?

This is because the velocity is applied relative to attachment0 but the velocity you’re calculating is relative to the world

Change
linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
to
linearVelocity.RelativeTo = Enum.ActuatorRelativeTo.World

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.