local key = "B"
local Player = game.Players.LocalPlayer
local Character = Player.Character
local AnimationID = "4725687163"
local CharAnimation
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode[key] then
animation()
end
end)
function animation()
if Character then
local idleanimation = Character:FindFirstChild("AnimationCharacter")
if CharAnimation then
CharAnimation:Stop()
end
if idleanimation then
if idleanimation.AnimationId=="rbxassetid://"..AnimationID then
idleanimation:Destroy()
return
end
idleanimation:Destroy()
end
local Animation =Instance.new("Animation",Character)
Animation.Name= "AnimationCharacter"
Animation.AnimationId = "rbxassetid://"..AnimationID
CharAnimation= Character.Humanoid:LoadAnimation(Animation)
CharAnimation:Play()
end
end
Here’s a script that makes the player play the animation whenever B is pressed. How do I make it so that the animation will not play clicking B while you are typing a message?
This is a script inside of StarterGui.