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.
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?
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.
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)