Flipping around like a fish even though I eliminated all momentum

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Dash punch animation / input.

  2. What is the issue? I flip around like a fish, I also eliminated all momentum after anchoring myself.

Part.Touched:Connect(function(Hit) -- Part is the hitbox around the player.
		print(Hit) -- Just for bug checks
		if Hit.Parent ~= Humanoid.Parent then -- If part we touch isn't apart of the players body
			HRP.Anchored = true -- HumanoidRootPart.Anchored = true
			force:Destroy() -- Linear force.
			attachment:Destroy() -- Attachment for the linear force.
			game:GetService('RunService').Heartbeat:Wait() -- Wait for one frame.
			Character.PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0) -- Stops all momentum???
			HRP.Anchored = false -- HumanoidRootPart.Anchored = false
		end
	end)
  1. What solutions have you tried so far? Majority of things, not everything.

Heres my full script, also if you have any ways to optimize this please tell me.

local RemoteEvent = game.ReplicatedStorage.RemoteEvents.DashEvent

local function Instancer(OriginalPart, Override, Size, CanCollide)
	if Override == true then
		local Part = Instance.new('Part')
		Part.Name = 'HitBox'
		Part.Color = Color3.new(1, 0, 0)
		Part.Size = Vector3.new(Size,1,Size)
		Part.Position = OriginalPart.Position
		Part.CanCollide = CanCollide
		local Weld = Instance.new('Weld')
		Weld.Part0 = Part
		Weld.Parent = Part
		Weld.Part1 = OriginalPart
		Part.Parent = OriginalPart
		
		return Part
	else
		local Part = Instance.new('Part')
		Part.Name = 'HitBox'
		Part.Color = Color3.new(1, 0, 0)
		Part.Size = Vector3.new(OriginalPart.Size.X*1.1,OriginalPart.Size.Y*1.1,OriginalPart.Size.Z*1.1)
		Part.Position = OriginalPart.Position
		local Weld = Instance.new('Weld')
		Weld.Part0 = Part
		Weld.Parent = Part
		Weld.Part1 = OriginalPart
		Part.Parent = OriginalPart

		return Part
	end
end

RemoteEvent.OnServerEvent:Connect(function(Player, Input)
	local Character = Player.Character
	local Humanoid = Character:FindFirstChildWhichIsA('Humanoid')
	local HRP = Character:WaitForChild('HumanoidRootPart')

	local force = Instance.new("LinearVelocity", HRP)
	local attachment = Instance.new("Attachment", HRP)

	force.MaxForce = math.huge
	force.VelocityConstraintMode = Enum.VelocityConstraintMode.Vector
	force.Attachment0 = attachment
	force.RelativeTo = Enum.ActuatorRelativeTo.Attachment0

	attachment.WorldPosition = HRP.AssemblyCenterOfMass

	game:GetService('Debris'):AddItem(force, 0.5)
	game:GetService('Debris'):AddItem(attachment, 0.5)
	
	local Part = Instancer(HRP, true, 5, false) -- HITBOX
	
	game:GetService('Debris'):AddItem(Part, 1)
	
	Part.Touched:Connect(function(Hit) -- Part is the hitbox around the player.
		print(Hit) -- Just for bug checks
		if Hit.Parent ~= Humanoid.Parent then -- If part we touch isn't apart of the players body
			HRP.Anchored = true -- HumanoidRootPart.Anchored = true
			force:Destroy() -- Linear force.
			attachment:Destroy() -- Attachment for the linear force.
			game:GetService('RunService').Heartbeat:Wait() -- Wait for one frame.
			Character.PrimaryPart.AssemblyLinearVelocity = Vector3.new(0, 0, 0) -- Stops all momentum???
			HRP.Anchored = false -- HumanoidRootPart.Anchored = false
		end
	end)

	if Input == 'W' then
		-- Forward
		force.VectorVelocity = Vector3.new(0,0,-65)
	elseif Input == 'A' then
		-- Left
		force.VectorVelocity = Vector3.new(-65,0,0)
	elseif Input == 'S' then
		-- Backward
		force.VectorVelocity = Vector3.new(0,0,65)
	elseif Input == 'D' then
		-- Right
		force.VectorVelocity = Vector3.new(65,0,0)
	end
end)


-- HRP.CFrame is the position? Its also called the offset.
-- HRP.CFrame.LookVector is where the player is facing?
-- 50 is the studs.
-- HRP.CFrame is setting the position of where we are going to muliply 50 studs in the direction of the lookvector.
1 Like

Tried so many solutions, nothing worked besides using less MaxForce. I changed it to this, still causes them to climb up the wall but it works.

force.MaxForce = 50000

Heres all my failed solutions, if you wanted to see any potentially working solutions for your games.

--Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
			--Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, false)
			--Humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics, false)
			
			--wait(1)
			
			--Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, true)
			--Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown, true)
			--Humanoid:SetStateEnabled(Enum.HumanoidStateType.Physics, true)
			
			---------------------------------------------------------------------------------------------------------------------------------
			
			-- First Step of making sure the player doesn't fling is stopping animations
			--for i,v in pairs(Humanoid:GetPlayingAnimationTracks()) do
			--	print(v)
			--	v:Stop()
			--end
			-- Second Step is Anchoring
			--HRP.Anchored = true -- HumanoidRootPart.Anchored = true
			--wait(0.25)
			--local BodyGyro = Instance.new('BodyGyro')
			--BodyGyro.CFrame = Character:GetPivot()
			--BodyGyro.Parent = Character
			--for _, Descendant in ipairs(Character:GetDescendants()) do
			--	if not (Descendant:IsA("BasePart")) then continue end
			--	Descendant.AssemblyLinearVelocity = Vector3.new(0, 0, 0)
			--	Descendant.AssemblyAngularVelocity = Vector3.new(0, 0, 0)
			--end
			--wait(0.25)
			--HRP.Anchored = false -- HumanoidRootPart.Anchored = false
			
			---------------------------------------------------------------------------------------------------------------------------------
			
			--Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, false)
			--HRP.Anchored = true -- HumanoidRootPart.Anchored = true
			--force:Destroy() -- Linear force.
			--attachment:Destroy() -- Attachment for the linear force.
			--game:GetService('RunService').Heartbeat:Wait() -- Wait for one frame.
			--HRP.Velocity = Vector3.new(0, 0, 0) -- Stops all momentum
			--HRP.Anchored = false -- HumanoidRootPart.Anchored = false
			--delay(0.5, function()
			--	Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll, true)
			--end)
1 Like