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

What is the best way to immobilize players?

Asked by
asadefa 55
5 years ago

I am making a tool that takes about a second to use start to finish, and I want to make the user not be able to fall or anything while using the tool. I tried to anchor the HumanoidRootPart but I am not quite sure that this is the best approach to take. What is the best way to immobilize players?

2 answers

Log in to vote
2
Answered by
lysandr 49
5 years ago

There are a variety of ways to immobilize a player's character model. I'll jot a few down.

1) Set the Humanoid's state to PlatformStand, however this won't stop them from falling.

 humanoid:ChangeState(Enum.HumanoidStateType.PlatformStand)

2) Though not as practical you could try welding the HumanoidRootPart to an anchored part.

local weld = Instance.new("WeldConstraint")
weld.Part0 = HumanoidRootPart
weld.Part1 = AnchoredPart
weld.Parent = HumanoidRootPart

3) Anchoring the HumanoidRootPart tends to bug out a lot so I wouldn't suggest this but you can always try it as an alternative.

4) Setting the humanoid's JumpPower and WalkSpeed both to 0 would stop them from jumping and walking but not stop them from falling.

Those are just some methods off the top of my head, keep in mind the client can always manipulate the humanoid and it's model via Filtered Enabled exploits.

Ad
Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

As you described, one way to do this is to Anchor the player.

Local Script

local player = game.Players.LocalPlayer
player.Character.HumanoidRootPart.Anchored = true

Another way to do this is to make the player's Walkspeed 0, like so

local player = game.Players.LocalPlayer
player.Character.Humanoid.WalkSpeed = 0

This will work for players when they first enter the game, but what about after their WalkSpeed is returned to 16?

If you want to make sure the player can't move you'll need to add a custom (LocalScript) Control Script (you can also copy this when you join the game in a test server) to the StarterPlayerScripts, then if you set the ControlScript Parent to the Replicated Storage, like so:

local player = game.Players.LocalPlayer
player.PlayerScripts.ControlScript.Parent = game.ReplicatedStorage

they will be unable to move, and this can be reversed by doing the opposite

local player = game.Players.LocalPlayer
game.ReplicatedStorage.ControlScript.Parent = player.PlayerScripts

This has the benefit of being able to force the player to move to a location if you want them to

0
"player.Character.Humanoid.Anchored = true" You cannot anchor the Humanoid, I assume you meant the HumanoidRootPart? lysandr 49 — 5y
0
yep, lol copied the other line with humanoid to add this line, but forgot to edit that SerpentineKing 3885 — 5y

Answer this question