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
You override the "animation" variable by creating a function with the same name.
local a = 1 print(type(a)) --> number local function a() end print(type(a)) --> now it's a function!
Rename animation() to something else, and you also need to call the function afterwards or it won't do anything