I want to prevent the player from moving, and thus anchored their HRP as well as set their WalkSpeed and JumpPower to 0. However, they walk animation continues to play when this function is fired. I originally was unbinding the movement controls, which worked well, but have had to stop doing that, as then the WASD keys become a GameProcessedEvent, which breaks other aspects in my game.
return function(active)
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:FindFirstChild('HumanoidRootPart')
if not HumanoidRootPart then return end
local Humanoid = Character:FindFirstChild('Humanoid')
if not Humanoid then return end
-- Disable movement
HumanoidRootPart.Anchored = not active
Humanoid.JumpPower = active and 40 or 0
Humanoid.WalkSpeed = active and 18 or 0
end