:ApplyImpulse() not working on players

Hello,
before i explain more, i want to say that i did look for other forums, they were not usefull to me.
So im making a dropkick system and want to deal knockback to players, it does work on a rig but it doesnt work on a player, check the video

i could give the full script if really is needed, this is the snippet of code where the plr should get knockback:

enHrp:ApplyImpulse(myhrp.CFrame.LookVector * 2000) -- gooi die force hoger als het moet

Any help is appreciated!

2 Likes

Are you using a script or a local script? You can’t ApplyImpulse a part owned by a player from the server.

Im using a serverscript in serverscriptservice

Then to do this you could fire a remote event to the client so you can ApplyImpulse to the HumanoidRootPart.

It’s not that :ApplyImpulse() isn’t working, but rather the method that you are using to run the built in function.

When dealing with knockback, or applying velocity to another humanoid in general, it’s recommended that you just replicate the impulse on the opponent’s client.

Since you mentioned that the function is contained in a serverscript, what you can do instead is;

  1. Include a .OnClientEvent in the local script that detects if they were a victim.

  2. Get the opponent via any detection method via shapecasting, raycasting, gettouched, etc..

  3. Next, fire to the server with the player you just detected. e.g :FireServer(opponent)

  4. In the server event, fire the other remote used for .OnClientEvent using :FireClient(opponent).

And now you put the :ApplyImpulse() function within the client event, and it should work if you did everything correctly!

I did this all from memory, but I’m certain this i’ll work. If not, I can remake your script later today iyw.

10 Likes

imma make second client script ig, im going to update you all what happend

This is because characters have different network owners, each having that as their player. In this case you want to be applying the Impulse from the recievers client in order to get a server wide result as their computer is handling their character physics.

1 Like

So if this is correct (which this doent work) it should throw the opponent:

remote:FireClient(plr, enPlr)

client:

remote.OnClientEvent:Connect(function(clr : Player, clr2)
	if clr then
		local har = clr.Character
		local enHrp = har:WaitForChild("HumanoidRootPart")
		enHrp:ApplyImpulse(mytorso.CFrame.LookVector * 2000) -- gooi die force hoger als het moet
	end
end)

I dont know how fireclient thinys work so if u see a mistake, lmk.

Please teach me im really lost.

Futher info:

plr = remote.OnServerEvent:Connect(function(plr : Player
enPlr = local enPlr = game.Players:GetPlayerFromCharacter(enchar)

Update: fire all clients seemed to work, now i have to change the one who gets flung

Update2: it worked!
Conclusion:
If pusle no no work, you do fire client :+1:
Thanks to everyone contributing to this post!

4 Likes

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