I’m trying to play an animation that was inserted after being loaded in a function, however when i try to play it, i get the error attempt to call missing method 'Play' of table
local __REALANIMATIONS = {}
function __LOADANIMATION(__HUM: Humanoid?, __ANIM: Animator?)
local __ANIMATIONS = {
script:FindFirstChild("HITATTACK1")
script:FindFirstChild("HITATTACK2")
}
if __HUM then
if __HUM:FindFirstChild(__ANIM) then
__ANIM:LoadAnimation(__ANIMATIONS)
table.insert(__REALANIMATIONS, __ANIMATIONS)
end
end
end
LocalPlayer.CharacterAdded:Connect(function(__MODEL)
__LOADANIMATION(__MODEL:FindFirstChildOfClass("Humanoid"), __MODEL:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator"))
end)
function __INPUT(Input: InputObject?, ...)
print(...)
if Input == "RMB" then
__REALANIMATIONS:Play()
end
end
local __REALANIMATIONS = {}
function __LOADANIMATION(__HUM: Humanoid?, __ANIM: Animator?)
local __ANIMATIONS = {
script:FindFirstChild("HITATTACK1")
script:FindFirstChild("HITATTACK2")
}
if __HUM then
if __HUM:FindFirstChild(__ANIM) then
for i, v in _ANIMATIONS do
__ANIM:LoadAnimation(v):Play()
table.insert(__REALANIMATIONS, __ANIMATIONS)
end
end
end
end
LocalPlayer.CharacterAdded:Connect(function(__MODEL)
__LOADANIMATION(__MODEL:FindFirstChildOfClass("Humanoid"), __MODEL:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator"))
end)
function __INPUT(Input: InputObject?, ...)
print(...)
if Input == "RMB" then
__REALANIMATIONS:Play()
end
end
u cant just use :Play() in the table because the table dont is an animation, so the solution is, make a for loop on the table and run the animations, i hope that this helped
local __REALANIMATIONS = {}
function __LOADANIMATION(__HUM: Humanoid?, __ANIM: Animator?)
local __ANIMATIONS = {
script:FindFirstChild("HITATTACK1");
script:FindFirstChild("HITATTACK2");
}
if __HUM then
if __HUM:FindFirstChild(__ANIM) then
for i,v in __ANIMATIONS do
table.insert(__REALANIMATIONS, __ANIM:LoadAnimation(v))
end
end
end
end
LocalPlayer.CharacterAdded:Connect(function(__MODEL)
__LOADANIMATION(__MODEL:FindFirstChildOfClass("Humanoid"), __MODEL:FindFirstChildOfClass("Humanoid"):FindFirstChildOfClass("Animator"))
end)
function __INPUT(Input: InputObject?, ...)
print(...)
if Input == "RMB" then
__REALANIMATIONS[math.random(1, #__REALANIMATIONS)]:Play()
end
end