Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to stop command emote animation the second time?

I made a script with emotes. For example if you type /hands then an animation plays. What I want is that if the character says /hands again then the animation stops. Please help :)

Code:

local players = game:GetService("Players")

local command1 = "/hands"

function onChatted(chat, recipent, speaker)
	local name = speaker.Name
	chat = string.lower(chat)
	
	if (chat == command1) then
		local player = players:FindFirstChild(name)
		local Humanoid = player.Character.Humanoid

		
		local ActiveTracks = Humanoid:GetPlayingAnimationTracks()
		for _,v in pairs(ActiveTracks) do
			v:Stop()
		end
end

function onPlayerEntered(player)
	player.Chatted:Connect(function(chat,recipent) onChatted(chat,recipent,player) end)
end

game.Players.PlayerAdded:Connect(onPlayerEntered)

Thank you for taking your time!

1 answer

Use If Functions Example:

local On = false
if not On then
	print("On Is False")
	On = true
else
	print("On Is True")
	On = false
end

This discussion is preserved as it was. New answers, comments, and votes are closed.