I’ve seen as my animate script has taken up too much space I would use a module to get the instances instead of storing them as variables. It’s just an opinion thing, but I haven’t found a get around of this one error.
Oh, I read the error one more time and decided to check the docs. Animation and AnimationTracks are different, with AnimationTracks possessing IsPlaying.
Only then the said property will be accessible upon calling LoadAnimation, which returns an AnimationTrack.
The LoadAnimation function itself returns an AnimationTrack which you should catch. And also, I don’t believe loading the Animations every time they are fetched is good practice. Try this (code untested):
local Ancestor = script.Parent
local MovementAnimations = Ancestor.MovementAnimations
local WeaponAnimations = Ancestor.WeaponAnimations
local Players = game:GetService("Players")
local Client = Players.LocalPlayer
local Client_Character = Client.Character or Client.CharacterAdded:Wait()
local Client_Humanoid = Client_Character:FindFirstChildWhichIsA("Humanoid")
local Client_Animator = Client_Humanoid:FindFirstChildWhichIsA("Animator")
local AnimationSettings = {
["MovementAnimations"] = {
["Idle"] = MovementAnimations.Idle,
["Walk"] = MovementAnimations.Walk
},
["WeaponAnimations"] = {
["Idle"] = WeaponAnimations.Idle,
["Mouse1"] = WeaponAnimations.Mouse1,
["Parry"] = WeaponAnimations.Parry
}
}
local function loadAnimations(t)
local Contents = {}
for Name, Value in t do
local Type = typeof(Value)
if Type == "table" then
Contents[Name] = loadAnimations(Value)
elseif Type == "Instance" then
if Value:IsA("Animation") then
Contents[Name] = Client_Animator:LoadAnimation(Value)
end
end
end
return Contents
end
AnimationSettings = loadAnimations(AnimationSettings)
function AnimationSettings.fetchMovementAnimation(Name)
return AnimationSettings.MovementAnimations[Name]
end
function AnimationSettings.fetchWeaponAnimation(Name)
return AnimationSettings.WeaponAnimations[Name]
end
return AnimationSettings