Player Animation not playing

Hi there, I’m attempting to play the default wave animation on a player. This snippet is from a local script parented to a GUI in the PlayerGui folder. This was pulled from Roblox docs, though it doesn’t function or give any errors.

 local player = game.Players.LocalPlayer

    local character = player.Character
    local humanoid = character:FindFirstChild("Humanoid")

    local animation = Instance.new("Animation")
    animation.AnimationId = "http://www.roblox.com/asset/?id=507770239"

    local animationTrack = humanoid:LoadAnimation(animation)
    animationTrack:Play()
    

The basic functionality of this is to make the player wave, then return to the regular idle animation.

Do you want the animation to play when you click the GUI?

Otherwise look under Changing Default Animations in this:

Hi!

Make sure the character is a thing when you define “character”. :smiley:

local character = player.Character or player.CharacterAdded:Wait()