How to prevent character from rotating?

Hi! Im making dash system and when im dashing into part or other character i am fling yourself, how to fix that?

local function Dash(Player, Direction, dashAnim)
	local Character = Player.Character
	local Humanoid = Character:FindFirstChild('Humanoid'):: Humanoid
	
	local Velocity = Instance.new('LinearVelocity')
	Velocity.Parent = Character.HumanoidRootPart

	Velocity.MaxForce = math.huge
	Velocity.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
	Velocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0

	local Attachment = Instance.new('Attachment')
	Attachment.Parent = Character.HumanoidRootPart

	Velocity.Attachment0 = Attachment
	local Anim = Humanoid:LoadAnimation(dashAnim)
	Anim:Play()

	RemoteEvents.Dash:FireClient(Player, true)

	if Direction == 'Front' then
		if Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
			Velocity.VectorVelocity = Vector3.new(0, -10, -65)
		else
			Velocity.VectorVelocity = Vector3.new(0, 4, -65)
		end
	elseif Direction == 'Right' then
		if Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
			Velocity.VectorVelocity = Vector3.new(65, -10, 0)
		else
			Velocity.VectorVelocity = Vector3.new(65, 4, 0)
		end
	elseif Direction == 'Left' then
		if Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
			Velocity.VectorVelocity = Vector3.new(-65, -10, 0)
		else
			Velocity.VectorVelocity = Vector3.new(-65, 4, 0)
		end
	elseif Direction == 'Back' then
		if Humanoid:GetState() == Enum.HumanoidStateType.Freefall then
			Velocity.VectorVelocity = Vector3.new(0, -10, 65)
		else
			Velocity.VectorVelocity = Vector3.new(0, 4, 65)
		end
	end

	game.Debris:AddItem(Attachment, 0.3)
	game.Debris:AddItem(Velocity, 0.3)

	task.wait(0.5)

	RemoteEvents.Dash:FireClient(Player, false)
end
1 Like

When you set a LinearVelocity’s MaxForce to math.huge (infinity), you’re essentially giving it permission to use as much force as required to reach the desired velocity. As a consequence, if the character collides with another object, the LinearVelocity will rapidly increase its force to try to keep the character’s velocity equal to the desired velocity, causing the character to get flung

There are two ways you can fix this problem, you can either limit the LinearVelocity’s MaxForce, or you can use ApplyImpulse instead (this is what I normally use when making a dashing system)

Ok, thanks you im gonna use 1 variant

1 Like

Yea! Tysm, i am set LinearVelocity.MaxForce to 20000 and this works

1 Like

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