I'm trying to make an animation play as shown in the function however, the outputs always prints out an error: attempt to index function with 'Play' which is the :Play() part I don't seem to know what is causing the error and how to fix it.
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local animationid = game.ReplicatedStorage.Animation
local animation = humanoid:LoadAnimation(animationid)
local function animation()
animation:Play() -- ERROR LINE
end
