ApplyImpulse doesn't work

I’m trying to achieve a knockback effect using ApplyImpulse as I read it was better;

I tried doing the same thing but it had no effect, here’s my code (LocalScript):

local function Knockback(hit)
	if hit.Parent:FindFirstChild("HumanoidRootPart") then
		local hrp = hit.Parent:WaitForChild("HumanoidRootPart")
		local power = Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * hrp:GetMass() * workspace.Gravity * GameSettings.KBSpeed
		--local power = Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * 2000
		print(power)
		hrp:ApplyImpulse(power)
	end
end

The output of the print is

-651615.75, -0, -884637

and “GameSettings.KBSpeed” is 2000, I tried 30 for the first time but it also didn’t work.
I tried searching for solutions and all I found was that their power was too low (which I don’t think is my case) and that the physics didn’t work on npcs since it was made by the Server (unless I misunderstood)

so I tried using it on a test server with two players, yet it still didn’t work.

Any ways to fix this? Thanks

1 Like

Strange… are you sure it’s client-sided? The server can’t apply physics on client-owned parts. Also, what’s the purpose of workspace.Gravity being part of the equation?

1 Like

Yes, it’s all in a Local Script in StarterCharacterScripts > Folder.

Honestly, I have no idea what workspace.Gravity does but I tried:

and still does the same thing.
Using that code instead, I get a different output but similar outcome

And you sure the part being affected is also owned by this client?

1 Like

I tried setting the HumanoidRootPart’s NetworkOwner to nil and nothing happened but when I tried to do so with the player, it worked.

How would I apply this to players though? Would I need to set the network owner of every humanoidrootpart to the player who attacked?

This knockback effect is for a combat system, so I would have to set their network owner to the player dealing the attack, but brings up concerns for multiple players attacking the same person.

Have the server use a remote event that tells the client that it received some knockback. There’s no need to force network owner here.

2 Likes

Im not sure what you mean here
Did you mean it doesn’t work for NPCs or what? I dont believe you can set the network ownership of a Player object.

I would believe you want to apply the knockback on the server by either directly setting the AssemblyLinearVelocity or by using a VectorForce object (not 100% sure if these are the best methods ngl)

1 Like

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