How can I disable the player in an efficient way? Other methods have problems

I want to disable the player’s movement and jumping, not just pausing them in air like how velocity does.
Some methods I tried:

ContextActionService:BindAction(
			FREEZE_ACTION,
			function() return Enum.ContextActionResult.Sink end,
			false,
			unpack(Enum.PlayerActions:GetEnumItems())
		)

--enable
	ContextActionService:UnbindAction(FREEZE_ACTION)

The problem with this method is that it doesn’t work for mobile players, and that sometimes when you walk and get disabled by this, it makes you walk in that direction and you can’t stop.

Controls method:

local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
            controls:Disable()
            wait(3)
            controls:Enable(true)

The problem with this method is when you respawn your controls are disabled and you can’t enable them back.

What other method can I use to disable the player other than these methods, or am I doing something wrong?

2 Likes

I’ve always just anchored the player’s HumanoidRootPart. It’s the easiest way that I know of. The only issue with it is that exploiters can thaw themselves.

2 Likes

You can force the player to not move right after that, Vector3.new(0,0,0).

1 Like

But I don’t want the player to freeze in midair, just to drop down and be disabled.

Can you explain a bit further? Is what you mean force the player to move where they are right now?

The API I provided in combination with CAS method should ensure that the players are not moving when the parameter assigned is Vector3.new(0, 0, 0). By not moving, you force them to stand still. If that API doesn’t work for reasons of replication, use this one as an alternative:

It’s a bit overkill, but it will definitely work.

1 Like

Just set player walkspeed to 0

for eg:

local player = game.Players.LocalPlayer
local humanoid = player.Character.Humanoid

humanoid.WalkSpeed = 0 -- Default speed is 16.

To pop onto the bandwaggon - wouldn’t letting the player falling down to the floor then anchoring the HumanoidRootPart be a solution? If there is a concern about hackers “unthawing” themself, then a simple while true do statement would work aswell. Just my thoughts though

I don’t want to do that, I have other scripts that slow down the player, instead I would do
humanoid.WalkSpeed - 16, BUT, if the player is 16 walkspeed or more than they can still walk and I just wanna avoid using walkspeed because I have classes that slow players then give their speed back

I already explained the issues on there, I don’t like those methods

1 Like

also, I have an animation that plays so anchoring the player is a problem for the animation.

I’m no master at animation but - doesn’t the animation system only move parts for vanity? I’ve never seen animations + anchoring HRP being an issue

Set both WalkSpeed and JumpPower to 0 in their Humanoid.

If you want them frozen from the start do it from StarterPlayer.

Is there any other way to disabled other than WalkSpeed nad JumpPower?

Maybe trying to disable the script for the player movement. Like This:

local controls = require(game.Players:GetPlayerFromCharacter(--[[what you use for the attack]]).PlayerScripts.PlayerModule):GetControls()
controls:Disable()

If you don’t mind animations stopping, just do

for i,v in pairs(char:GetDescendants()) do
    if v:IsA("Part") or v:IsA("MeshPart") then
        v.Anchored = true
    end
end

maybe anchor humanoidrootpart maybe

Make players humanoidRootPart anchored. This will freeze them.

i already explained that when you use this you cant enable yourself when you respawn

i dont want to anchor i want to disable them from movement, they just drop down.