Just started using animations, ok back to question, I want someone in my game to click a key and it trigger an animation, its not working, dont remember where i snagged this script from but no matter what i change/do it doesnt work.
heres the script
local animkey = "Q"
local Player = game.Players.LocalPlayer
local Character = Player.Character
local AnimationID = "3823158750"
local CharAnimation
game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
if inputObject.KeyCode == Enum.KeyCode[animkey] then
animation()
end
end)
function animation()
if Character then
local UseLessAnimation = Character:FindFirstChild("AnimationCharacter")
if CharAnimation then
CharAnimation:Stop()
end
if UseLessAnimation then
if UseLessAnimation.AnimationId=="rbxassetid://"..AnimationID then
UseLessAnimation:Destroy()
return
end
UseLessAnimation:Destroy()
end
local Animation =Instance.new("Animation",Character)
Animation.Name= "AnimationCharacter"
Animation.AnimationId = "rbxassetid://"..AnimationID
CharAnimation= Character.Humanoid:LoadAnimation(Animation)
CharAnimation:Play()
end
end

4 comments
Opps i had forgotten the animation ID, but fixed now.
Still doesnt seem to work, I have the script in a local script in starter player scripts, is that the right place?
You will have to put inside Starter Character Scripts. If you put it in starterplayer you will have some errors in getting the char with this script, it would had to be written in a different way, and the script would stop working once the char dies.
I just saw I forgot to write "local" before the variable "AnimationTrack" in line 11. Hope you noticed that.