The easiest way to do this would be through StarterPlayer. Why don’t you just set StartPlayer.CharacterWalkSpeed to 0, and the same with jump power? You don’t need a script to do this.
Way #2
You can also change the walkspeed and jump power of the humanoid (through script)
If you are familiar with ModuleScripts, one I always include in my games is the following:
-- ModuleScript
local PlayerMovement = {}
function PlayerMovement:Movement(Player, move)
local ContextActionService = game:GetService("ContextActionService")
local FREEZE_ACTION = "freezeMovement"
if move == false then
ContextActionService:BindAction(
FREEZE_ACTION,
function()
return Enum.ContextActionResult.Sink
end,
false,
unpack(Enum.PlayerActions:GetEnumItems())
)
elseif move == true then
ContextActionService:UnbindAction(FREEZE_ACTION)
end
end
return PlayerMovement
-- Local Script
local PlayerMovement = require(PlayerMovement)
PlayerMovement:Movement(game.Players.LocalPlayer, false) -- stop movement
PlayerMovement:Movement(game.Players.LocalPlayer, true) -- allow movement
Now, keep in mind. When you stop movement, it wont allow the Player to:
-- this is a local script
local ContextActionService = game:GetService("ContextActionService")
local function sink()
return Enum.ContextActionResult.Sink
end
-- Freeze player (have this part run when you want the character to freeze)
-- make sure the player and character have loaded already
ContextActionService:BindAction(
"Freeze", -- action name (this is used to unbind action)
sink, -- function that is called when action activates
false, -- if true creates a touch button for mobile
unpack(Enum.PlayerActions:GetEnumItems()) -- list of actions (all player actions)
)
Then if you want to unfreeze the player:
-- code to unfreeze player
ContextActionService:UnbindAction("Freeze")
Hello! I happen to see this as I am hardly active on the forum like before.
In regards to your question:
Referring back to earlier in the post:
This method should work on any device, as it is not keybind-related or device-specific. The function actually unbinds the Core script’s built-in movement scripts. Therefore, the player cannot move until they are restored (which is done when you tell the module to allow movement again).