Hello, I would like to know what I am doing wrong I need to make when I press the G key the animation plays, just that
local animation = Instance.new("Animation")
animation.AnimationId = "https://www.roblox.com/asset/?id=6351842291"
local AnimationController = script.AnimationController
local animationTrack = AnimationController:LoadAnimation(animation)
local UserInputService = game:GetService("UserInputService")
local function onInputBegan(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.G then
-- code
animationTrack:Play()
else
animationTrack:Stop()
end
end
UserInputService.InputBegan:Connect(onInputBegan)