Player Gets Knocked Down Every Single Time Intercepted

I’m trying to get a perfect roll if the player gets intercepted by a wall I just simply want him to either get pushed back or just stop.
Currently whenever the player rolls or uses any sort of ability that sends them forward and they hit something it causes the player to glitch out then fall back and just lie there.
I tried using my anti trip command I use on the bosses in this game (ran in a do-while loop):

_G.antiTrip=function(char)
	if char.Humanoid:GetState()==Enum.HumanoidStateType.FallingDown then
		char.Humanoid:ChangeState(2)
	end
	if char.Humanoid:GetState()==Enum.HumanoidStateType.Ragdoll then
		char.Humanoid:ChangeState(2)
	end
end

This sadly didn’t give me what I wanted (It was very awkward).

This happens many times, here is a gif when I hit intercept an invisible wall in the lobby.
xU9iA5mvkG
Current Roll Code:

remotes.Roll.OnServerInvoke=function(plr, mouseVector, mouseTarget)	
	local fodler = _G.getFolder(plr.Name)
	if fodler:FindFirstChild("Loading")~=nil then
		repeat wait() until fodler:FindFirstChild("Loading")==nil
	end
	if game.ServerStorage.PlrModules:FindFirstChild(plr.Name)~=nil and game.ServerStorage.PlrModules:FindFirstChild(plr.Name).Stats.canRoll.Value==true then
		spawn(function()
			game.ServerStorage.PlrModules:FindFirstChild(plr.Name).Stats.canRoll.Value = false
			wait(8)
			game.ServerStorage.PlrModules:FindFirstChild(plr.Name).Stats.canRoll.Value = true
		end)
	else
		return
	end
	local module = require(game.ServerStorage.PlrModules:FindFirstChild(plr.Name).AttackHandler)
	local char = plr.Character
	local rato = char.Humanoid.Health/char.Humanoid.MaxHealth
	local power = game.ServerStorage.PlrModules:FindFirstChild(plr.Name).Stats.canRoll.rollPower.Value
	
	char.Humanoid.AutoRotate=false
	module.Cooldowns.useable=false
	game.ServerStorage.PlrModules:FindFirstChild(plr.Name).Stats.canRoll.isRolling.Value = true
	--game.ReplicatedStorage.ClientServer.StopAnimations:FireClient(plr)
	game.ReplicatedStorage.ClientServer.PlayAnimation:InvokeClient(plr, game.ServerStorage.AnimSets.Universal.Dive.Name)
	
	plr.Character.Torso.Dive:Play()
	
	local vel=Instance.new("BodyVelocity")
	if char.HumanoidRootPart.Velocity.magnitude>1 then
		vel.Velocity=char.HumanoidRootPart.Velocity.unit*100
	else
		vel.Velocity=char.HumanoidRootPart.CFrame.lookVector*100
	end
	
	char.HumanoidRootPart.CFrame=CFrame.new(char.HumanoidRootPart.Position, char.HumanoidRootPart.Position+vel.Velocity)	
	vel.MaxForce=Vector3.new(999999, 0, 999999)
	vel.Parent=char.HumanoidRootPart
	_G.Buff(char, char, "Defence", 1, 0.4)
	wait(.25)
	vel.Velocity=char.HumanoidRootPart.CFrame.lookVector*(30+(power/2)+(rato*(power/2+12.5)))
	wait(.2)
	vel.Velocity=char.HumanoidRootPart.CFrame.lookVector*(10+(power/2)+(rato*(power/2+7.5)))
	wait(.2)
	module.Cooldowns.useable=true
	game.ServerStorage.PlrModules:FindFirstChild(plr.Name).Stats.canRoll.isRolling.Value = false
	vel:Destroy()
	char.Humanoid.AutoRotate=true
	wait(.05)
end

(Current a Remote Function, Will be converted to remote event later on)

Humanoid state types are a bit of a hacky solution; there are ways to probably fix this by temporarily disabling some state types, and then restoring them, but this ignores the core issue.

I have a similar sort of mechanic, but it doesn’t use this issue. Pivotal differences:

  1. I handle the physics on the client, rather than the server. The client handles all of the local character physics, so it’s best to do it on the client.
  2. I set the velocity of the characters HumanoidRootPart directly, rather than using a BodyVelocity. This is more stable, because BodyVelocity is a legacy physics object (not guranteed to be fully compatible with the new physics solver, and additionally, it tends to be buggy with humanoids in my experience). If you wanted to, this would also allow you to more easily account for other forces, such as weight force (gravity) which will change the velocity of the HumanoidRootPart, because a BodyVelocity object “overrides” the velocity while its active.

You should do more things on the client in general. For example, the dive animation is better played locally for more instant feedback, and it’ll replicate automatically

2 Likes

turns out I should’ve just used my _G.Knockback() instead b/c its client and server sided and works really really well.