how do i disalbe walking without setting the walkspeed to 0
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.
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.
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)
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
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.
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)
oh finally! something that works! thank you so much bro
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.