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