How do you make a "push people" system?

I’m interested to learn how game creators make “push” system, as if the players will be pushed forward. Is this using a BodyForce or what? I’m not quite sure.

I know for one thing that there is going to be custom animation made, but in terms of scripting, how would I be able to do this?

Any help is appreciated, thanks.

2 Likes

There are a few ways of making a ‘push’ system. You can use either CFrame/Position manipulation or use physics to do it.

Using CFrame/Position can lead to glitches like going through walls so it isnt recommended for people new to the subject. (Requires lookvectors, CFrame prediction, raycasting)

Using physics has many options.
– Adding Velocity to the character
– Making A Object Force (BodyForce or similar)
– Using constraints to drag the character
– Pushing player with a part (When a part is inside another part, physics cause it to be pushed out, has loads of problems, dont do it)

I recommend adding the velocity directly to the character, its much safer and easier to monitor and control.

Steps to make them get pushed towards where you want them:

  • Work out the direction the velocity needs to be.
    if i am at 10,10,-50 and I want to get to -10,10,-40 I would apply negative X, nothing to the Y and Positive to the Z
  • Move the character by applying the a velocity until conditions are met (Can be multiple conditions encase they get stuck on a wall e.c.t). I would do max time of 1 sec or so and also check the position to see if the player goes within 2,2,2 of the target location
1 Like

It is full of YouTube tutorials

Don’t use YouTube videos, it will result in a poor copy of someone else’s work, if you are new to scripting, find your own way.

Many people copy others work from YouTube videos and the result is always a substandard product. This also means that the scripter learns very little from experimenting as the entire researching aspect of a project is removed when doing this. Researching via the APIs is essential otherwise you will get nowhere.

The only time you should use YouTube videos is to look for inspiration on how you can make your scripts surpass those before you.

6 Likes

I intend to take the basis of the script, the animation no

you could make it where if you hit someone give the hit player a body velocity that knocks them back and can make them sit.

Yeah, stuff like that, but will it be a gear or a button?

Do I need to determine the LookVector to know which direction for the bodyvelocity or how will this work?

@IOnlySayToxicPlayer What do you mean gear or button?
@minimic2002 Which method would you use out of all the options you mentioned?

I made a Roblox game in 5 minutes... - YouTube Watch AlvinBlox to be more sure what I mean

1 Like

Go ahead and there is the push script 0:50

Physics would be best as using CFrame or position can cause part clipping (Physics don’t like this when the manipulation ends, also leads to glitches like going thro walls if not done properly)

So using Physics is best in terms of easy set up and to reduce issues for those who arent advanced scripters.

it can be either one, just script them correctly and it’ll do the same thing if you want it to.

And how would I implement using Physics to a script? Would it be using BodyForce?

You could do that yeah, either can work if you just do it right.

bodyforce will work.

1 Like

You can directly set the velocity of a part to make it move
Here’s How:

Part.Velocity = Vector3.new(0,0,0) 

Vector3 is used in position and velocity so it would be easy enough to calculate the vector

You can calculate vectors easy enough, here’s something visual you can use if you struggle to understand how all the axis work together to reach a location.

3 Likes