Skip to main content
PointyLFish
Up and Coming
May 2, 2025
Question

Knock Back Player - Assistance - Much Appreciated!

Hello! I hope you're all doing well. I'm currently away from my computer but have my headset. I wanted to ask if someone would be able to  provide a clear breakdown with code blocks on how to implement a system where a player can pick up a sword, hit another player with it, and apply knockback? Since I'm using my headset at the moment, code block examples would be greatly appreciated. Thank you for your help! 

 

Cheers!

2 replies

SeeingBlue
Honored Contributor
May 2, 2025

If I recall, that biggest issue with something like this was just apply enough push to the player on the Y to lift them off the ground while applying the knock back. What part are you needing help with exactly?

Upcoming Events : Performance Pro - UI Unleashed - Building Responsive & Performant Interfaces Thursday June 19th 5:00 PM PT - Register June Programming Calendar
MKETheGuru
Inspiring
May 3, 2025

In my experience with making code block based knockback, I found it best to use a boolean at the start of the collision event to prevent it firing multiple times, also worth making sure the player being knocked back is not the same player holding the sword. We can turn the incoming motion of the sword into outgoing motion for the player by multiplying the relative velocity by -1. Taking it a step further, you can multiply this value by a number to scale up the knockback. Then, sending a delayed event to reset the boolean, you'll be set!

One important note: you'll want to be sure 'Custom Player Motion' is toggled on for the world. This can be found in the 'Player Settings' of the world.

 

It could look something like this when it's all done: 

Happy creating!

Upcoming Events : Build-Along - Sky’s The Limit - Create Stunning Custom Skydomes Tuesday June 3rd 11:00 AM PT - Register June Programming Calendar