Trouble getting the player to stop

Does anybody know how I can slow a player down if their going sideways or backwards?

I tried using the dot product but it keeps going into negative even tho i have a orientation alignment
( dont worry about the comment cols)
Script:

local function Flying()


	Connection = game:GetService("RunService").Heartbeat:Connect(function()
		local CameraDirection = char.UpperTorso.CFrame:ToObjectSpace(cam.CFrame).LookVector
		local PlrCh = char.UpperTorso.Position.Unit
		local PlrLook = char.UpperTorso.CFrame.LookVector
		local DotProduct = PlrCh:Dot(PlrLook)
		print(DotProduct)
		if hum.MoveDirection == Vector3.new(0,0,0) then
			LookCam.Enabled = false
			USG.RotationType = Enum.RotationType.MovementRelative
			hum.PlatformStand = false
			flyVel.Enabled = false
			--LookPos.Enabled = true
			char.LowerTorso.Root.C0 = CFrame.Angles(0,0,0)
			char.Head.Neck.C0 = CFrame.new(0,Yoffest,0) * CFrame.Angles(0,-math.asin(CameraDirection.X),0)
		else
			hum.PlatformStand = true
			LookCam.Enabled = true
			USG.RotationType = Enum.RotationType.MovementRelative
			LookCam.CFrame = cam.CFrame
			--char.Head.Neck.C0 = CFrame.new(0,Yoffest,0) * CFrame.Angles(0,0,0)
			--char.LowerTorso.Root.C0 = CFrame.Angles(0,-math.asin(CameraDirection.X),0)
			flyVel.Enabled = true 
			if DotProduct >= 0.5 then
				flyVel.VectorVelocity = cam.CFrame.LookVector * 50
			elseif 0.5 > DotProduct then
				flyVel.VectorVelocity = Vector3.new(0,0,0)
			end
				
			
			
			
			--hum.PlatformStand = true
			--LookPos.Enabled = true
		end
	end)

end

local velocity = HumanoidRootPart:GetVelocityAtPosition()

then apply a vector force that is the opposite of it that stops when the velocity of the root part is 0.

i tried using movedirection and the plrs hrp velocity none of them worked

got it to work all i did was use movedirection instead

		local DirectionFront = hum.MoveDirection:Dot(cam.CFrame.LookVector)

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