How to make player not able to do anything during emote

I want to make it where when the player emotes, they are not able to do anything like not being able to interact with any proximity prompts. Or not able to do anything.

local TheKeyYouWant = "T"
local Player = game.Players.LocalPlayer
local Character = Player.Character
local AnimationID = "17860810997"
local CharAnimation
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.T or inputObject.KeyCode == Enum.KeyCode.DPadDown then
		animation()
	end
end)
function animation()
	if Character then
		local UseLessAnimation = Character:FindFirstChild("AnimationCharacter")
		if CharAnimation then
			CharAnimation:Stop()
			Player.CameraMode = Enum.CameraMode.LockFirstPerson
			Character.DoorsCrouch.Enabled = true
			Character.Sprint.Enabled = true
			game.ReplicatedStorage.Audios.EmoteMusic:Stop()
			Character.Humanoid.WalkSpeed = 16
			Character.Humanoid.JumpHeight = 3.6
		end
		if UseLessAnimation then
			if UseLessAnimation.AnimationId=="rbxassetid://17860810997" then
				UseLessAnimation:Destroy()
				return
			end
			UseLessAnimation:Destroy()
		end
		local Animation =Instance.new("Animation",Character)
		Animation.Name= "AnimationCharacter"
		Animation.AnimationId = "rbxassetid://17860810997"
		CharAnimation= Character.Humanoid:LoadAnimation(Animation)
		CharAnimation:Play()
		game.ReplicatedStorage.Audios.EmoteMusic:Play()
		Character.DoorsCrouch.Enabled = false
		Character.Sprint.Enabled = false
		Player.CameraMode = Enum.CameraMode.Classic
		Character.Humanoid.WalkSpeed = 0
		Character.Humanoid.JumpHeight = 0
	end
end

Well you can disable the players controls:

As for prompts you’ll probably have to loop through all of them and set enabled to false on the client.
Note that exploiters will still be able to mess with this and do things any way, but at that point why bother

Like @FroDev1002 said, you can disable the controls on the client:

local player = game:GetService("Players").LocalPlayer
local controls = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule")):GetControls()

controls:Enable()
controls:Disable()
--or
controls:Enable(true)
controls:Disable(false)

For the other things, I would recommend setting an attribute and checking that attribute.

1 Like

I tried that but it didn’t work. Does this work on a client script?

Here’s the code but it failed.

local TheKeyYouWant = "T"
local Player = game.Players.LocalPlayer
local LocalPlayer = game:GetService("Players").LocalPlayer
local Character = Player.Character
local AnimationID = "17860810997"
local CharAnimation
local Controls = require(LocalPlayer.PlayerScripts.PlayerModule):GetControls()
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
	if inputObject.KeyCode == Enum.KeyCode.T or inputObject.KeyCode == Enum.KeyCode.DPadDown then
		animation()
	end
end)
function animation()
	if Character then
		local UseLessAnimation = Character:FindFirstChild("AnimationCharacter")
		if CharAnimation then
			Controls:Enable()
			CharAnimation:Stop()
			Player.CameraMode = Enum.CameraMode.LockFirstPerson
			Character.DoorsCrouch.Enabled = true
			Character.Sprint.Enabled = true
			game.ReplicatedStorage.Audios.EmoteMusic:Stop()
			Character.Humanoid.WalkSpeed = 16
			Character.Humanoid.JumpHeight = 3.6
		end
		if UseLessAnimation then
			if UseLessAnimation.AnimationId=="rbxassetid://17860810997" then
				UseLessAnimation:Destroy()
				return
			end
			UseLessAnimation:Destroy()
		end
		local Animation =Instance.new("Animation",Character)
		Animation.Name= "AnimationCharacter"
		Animation.AnimationId = "rbxassetid://17860810997"
		CharAnimation= Character.Humanoid:LoadAnimation(Animation)
		CharAnimation:Play()
		Controls:Disable()
		game.ReplicatedStorage.Audios.EmoteMusic:Play()
		Character.DoorsCrouch.Enabled = false
		Character.Sprint.Enabled = false
		Player.CameraMode = Enum.CameraMode.Classic
		Character.Humanoid.WalkSpeed = 0
		Character.Humanoid.JumpHeight = 0
	end
end