How do I fully stop the player from moving, like entirely freezing them, preventing them from even looking around? I tried to set the walkspeed to 0 but I was still able to move my camera, how would I approach this?
For context I want have an animation where the player presses a button on a wall, and to stop movement while doing so.
To summarize, how do I seize all control of the player’s movement until the animation ends.
Quick Question, are you playing the animation on a LocalScript or a Server Script?
if its on a LocalScript:
I Believe StarterPlayerScripts?
local Camera = workspace.CurrentCamera -- The Players Camera
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
-- Add Animation variables here then do the script below:
Character.Humanoid.WalkSpeed = 0
Camera.CameraType = Enum.CameraType.Scriptable -- You can use fix if you want (probably better)
Character.Humanoid.WalkSpeed = 16
Camera.CameraType = Enum.CameraType.Custom
For freezing movement, you could anchor the player’s HumanoidRootPart on the server. For the camera, you’d just change the CameraType to Fixed (or Scriptable if you’d like to adjust the camera at all during an animation).
Wanted to leave this here just in case you need it at a future time, for your use case the solution seems fine.
If you wanted the player to psychically move during the cutscene via a script (ie. :MoveTo or something), but have no control over there character whatsoever, you could use the following:
local ContextActionService = game:GetService("ContextActionService")
local Cam = workspace.CurrentCamera
ContextActionService:BindAction("Freeze", function() return Enum.ContextActionResult.Sink end, false, unpack(Enum.PlayerActions:GetEnumItems()))
Cam.CameraType = Enum.CameraType.Scriptable
-- player controlling itself is now disabled, however movement in itself is not.
Cam.CameraType = Enum.CameraType.Custom
-- player can control itself now.