I found this animation hotkey from the toolbox. Help, I want to make it when I press the key, activate the animation and when I press it again, it deactivate. Like a switch.
This is the script--
local player = game.Players.LocalPlayer local mouse = player:GetMouse()
function keyD(key) local key = key:lower() local hotkey = script.Hotkey.Value if key == hotkey then
local dance = Instance.new("Animation") dance.AnimationId = "rbxassetid://1506546104" local animloader = player.Character.Humanoid:LoadAnimation(dance) animloader:Play() end end
mouse.KeyDown:connect(keyD)
This should work :
local player = game.Players.LocalPlayer local mouse = player:GetMouse local dance = Instance.new("Animation") dance.AnimationId = "rbxassetid://1506546104" local animloader = player.Character.Humanoid:LoadAnimation(dance) local UIS = game:GetService("UserInputService") debounce = false UIS.InputBegan:Connect(function(Input, gameProcessedEvent) local KeyCode = Input.KeyCode if not gameProcessedEvent then if KeyCode == Enum.KeyCode.D and debounce == false then debounce = true animloader:Play() wait(3) debounce = false -- so it can be ran again after 3 seconds end end end)