How can I achieve this pushing ability?

  1. What do you want to achieve? a pushing ability like the one in the video below (ignore the side chatter)

  2. What is the issue? Not sure where to begin or how to achieve the “push” effect

  3. What solutions have you tried so far? none since I’m not the best scripter nor do I know a lot about roblox scripting.

please keep in mind that I’m not asking for scripts, I’m just looking for a push in the right direction.

1 Like

When a user uses MouseButton1 or left click, fire a raycast to see if it passes through any humanoids. If yes, apply a VectorForce to the humanoid. The rest of the settings is up to you. You can add debounce (cooldown), range (Raycast Params), etc.

2 Likes

I’m not very good with raycasts so I’ll look into those! Thank you : )

and set the humanoid state to 0 or ragdoll lol

1 Like

Use mouse instead (it’s easier and works for this use case). This is kind of a hard thing to script, at least it takes some more advanced concepts and instances.

First, created the client sided code:

  • Get the player from Players.LocalPlayer
  • Get the Mouse from Player:GetMouse
  • Make a connection to a Mouse click event
  • Use the Mouse.Target property to get the BasePart the mouse is aimed at
  • Check if the BasePart is part of a character
  • If it is, fire a remote event to the server with the character model

Second, on the server, handle the remove event:

  • When your code gets the remove event, use the player to get the pushing player’s character
  • Get the direction of the push (pushedCharacter.HumanoidRootpart.Position - pushingPlayer.Character.HumanoidRootpart.Position).Unit)
  • Multiply the directional vector by a number to make it as big as the force should be.
  • Add some upwards force (+ Vector3.new(0,upwardsForce,0))
  • Make the pushedCharacter sit with pushedCharacter.Humanoid.Sit = true
  • Use BasePart:ApplyImpluse(pushVector*HumanoidRootPart.AssemblyMass ) on the pushedCharacter’s HumanoidRootPart

Sorry for the long wordy instructions! It probably would have been faster for me to just program it :sweat_smile:.

2 Likes

Thank you so much for this! I’m gonna try to figure this out and make it, you’re definitely a big help : )