Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I fling a player effectively?

Asked by
trecept 367 Moderation Voter
5 years ago

I'm trying to fling a player properly so they go flying in a random direction. I've been trying to do this by changing the velocity of a player's humanoidrootpart, but they do not really get flung that well or in the way I want it to (didn't bounce around much). Is there a better way to get an effect of flinging a character? (I'm using R6 characters if this makes any difference)

1
`Player:FlingEffectivelyAsync()` User#24403 69 — 5y

1 answer

Log in to vote
3
Answered by
ee0w 458 Moderation Voter
5 years ago
Edited 5 years ago

In order to trip the character, you must use Humanoid:ChangeState() to manually change its state. We'll be focusing on the FallingDown state:

By doing Humanoid:ChangeState(Enum.HumanoidStateType.FallingDown), the Humanoid will fall to the floor unable to stand on its own. You can use this in conjunction with BasePart.Velocity to fling the character into the air. Here's an example of what I mean:

local p = 100
local rand = math.random
local char = ... -- However you'd get the character

char.Humanoid:ChangeState(Enum.HumanoidStateType.FallingDown) -- Change state to trip player
char.HumanoidRootPart.Velocity = Vector3.new(
    rand(-p,p),
    rand(-p,p),
    rand(-p,p)
)
p = p/10
char.HumanoidRootPart.RotVelocity = Vector3.new( -- Add rotation for extra fun
    rand(-p,p),
    rand(-p,p),
    rand(-p,p)
)

Here's it in action

Be sure to upvote/accept if I helped!

0
Amazing, thank you! trecept 367 — 5y
0
ur not supposed to set the velocity property of parts Gey4Jesus69 2705 — 5y
Ad

Answer this question