Disable walking

how do i disalbe walking without setting the walkspeed to 0

3 Likes

This may be what you’re looking for, however, a disclaimer is that this additionally disables the jump function:

-- services
local players = game:GetService("Players")

-- variables
local player = players.LocalPlayer
local playerScripts = player:WaitForChild("PlayerScripts")

local playerController = playerScripts:WaitForChild("PlayerModule")

-- modules
local controlModule = require(playerController:WaitForChild("ControlModule"))

-- functions
local function disableMovement()
	controlModule:Disable()
end

local function enableMovement()
	controlModule:Enable()
end

disableMovement()

This makes use of the PlayerModule module script found within the (Local)Player class.

5 Likes

thank you, but there is a problem. if i disable the player’s movement while the player is walking, the player continues to walk. i don’t know if that makes sense to you, but yeah.

2 Likes

After disabling it you could also set walk speed to zero or instead of disabling movement you could add a body velocity to the players humanoidRootPart and set its velocity to vector3.new(0,0,0) with a maxForce of vector3.new(10000,10000,10000)

2 Likes

Apologies for the mistake.

I’m making use of the Humanoid class within the player’s character to stop the character in place when disableMovement is called:

-- services
local players = game:GetService("Players")

-- variables
local player = players.LocalPlayer
local playerScripts = player:WaitForChild("PlayerScripts")

local playerController = playerScripts:WaitForChild("PlayerModule")

-- modules
local controlModule = require(playerController:WaitForChild("ControlModule"))

-- functions
local function disableMovement()
	controlModule:Disable()
	
	local character = player.Character
	
	-- guard clause to make sure the character exists
	if (not character) then return end
	
	local humanoid = character:FindFirstChild("Humanoid")
	
	-- another guard clause to make sure the Humanoid instance exists
	if (not humanoid) then return end
	
	humanoid:ChangeState(Enum.HumanoidStateType.GettingUp)
end

local function enableMovement()
	controlModule:Enable()
end

disableMovement()

I’m using the :ChangeState() method to alter the Humanoid’s current HumanoidStateType.

If the HumanoidStateType isn’t best fit for you, you can mess around with others here.

Hope this helps :slight_smile:

1 Like

the player still continues to walk after disabling it

Just set Humanoid.PlatformStand = true because in that way, you are freezing the character in place.

That works, but it makes the player fall on the ground for some reason.

You could run something like this … game.Players.LocalPlayer.Character:WaitForChild(“HumanoidRootPart”).Anchored = true
Even if it’s just to stop them moving, then do whatever else you’re trying …

Maybe just anchor their humanoid root part.

Anchoring the humanoidrootpart would make the players able to cheat in the game

Maybe create an anchored part where they are then weld them to it.

They should not be able to break the weld if the part and weld are created on the server.

You can compare their HumanoidRootPart.Position with the AnchoredPart.Position and ignore them if the two do not match.

I meant for just a moment.

game.Players.LocalPlayer.Character:WaitForChild(“HumanoidRootPart”).Anchored = true
Turn off run or whatever you’re doing …
game.Players.LocalPlayer.Character:WaitForChild(“HumanoidRootPart”).Anchored = false

Will stop a player in their tracks.

You could also try something like this … humanoid:Move(Vector3.new(0,0,0), false)
That would stop them moving and jumping.

1 Like

Can’t you just always cheat in some way anyway, lol?

if you change in StarterPlayer the way you walk to “Scriptable”?

(you should be able to change it to player objects too)

Oh? Well another method would be using ContextActionService and bind a ‘sink’ function to certain inputs - in our case, the character move set.

I wrote up a quick module:

-- services
local contextActionService = game:GetService("ContextActionService")

-- variables
local ACTION_BIND_NAME = "Movement"

local playerActions = Enum.PlayerActions:GetEnumItems()

-- functions
local function functionToBind()
	return Enum.ContextActionResult.Sink
end

return function(state: boolean)
	if (not state) then
		-- bind a 'sink' function to all player actions
		contextActionService:BindAction(ACTION_BIND_NAME, functionToBind, false, unpack(playerActions))
		
		return
	end
	
	-- unbind from the action if the state is true
	contextActionService:UnbindAction(ACTION_BIND_NAME)
end

And a base LocalScript to run said module:

-- modules
local movementController = require(script:WaitForChild("Movement")) -- location of the module

-- functions
local function enableMovement()
	movementController(true)
end

local function disableMovement()
	movementController()
end

disableMovement()

The LocalScript is located within StarterPlayerScripts but can be moved to any local environment you want.

Additionally, I created an emulator and a quick video showcasing that this works for me (R15 rigs)

2 Likes

oh finally! something that works! thank you so much bro :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.