✓ Accepted answer
I think the problem is that you used or in a variable. You should use a repeat until statement instead. Also, you will have to use the MouseButton1Click event and connect it to a function so the animation plays when you click it, make sure the script is a LocalScript, and make sure the gui instance is a TextButton.
local player = game:GetService("Players").LocalPlayer
repeat
wait()
until player.Character
local char = player.Character
local hum = char:WaitForChild("Humanoid")
local animation = hum:LoadAnimation(script.Animation)
script.Parent.MouseButton1Click:Connect(function()
animation:Play()
end)
And to answer your question, yes you should put the script with the animation inside the TextButton.