For some reason, GetChildren() is returning nothing within my Module Script, it should be returning the animations stored within the “Animations” folder, but it doesn’t seem to be doing that. Does anyone know why this issue is the way it is, and how I can fix it?
I’ve been looking around the Devforum for a while, and checking the developer hub, but I can’t find a solution.
MODULE SCRIPT
local AnimationsModule = {}
local Storage = game.ServerStorage.Animations
local AnimationStorage = {}
-- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | --
-- This Function loads in the animations into a character the moment that it is called.
function AnimationsModule:LoadAnimations(Player)
-- Test Stuff --
print (Player)
-- Script Variables --
local Char = Player.Character
local Humanoid = Char.Humanoid
-- Checks if the Player has an 'Animation' Account, if they do not, it creates one.
if AnimationStorage[Player.UserId] == nil then
AnimationStorage[Player.UserId] = {}
end
-- Script --
for i, Animation in pairs(Storage:GetChildren()) do
print ("YO! TEST! TEST!")
print (Animation.Name)
AnimationStorage[Player.UserId][Animation.Name] = Humanoid:LoadAnimation(Animation.AnimationId)
end
print (AnimationStorage)
end
-- | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | --
-- Testing Animation
function AnimationsModule:PlayAnimation(Player)
print(AnimationStorage[Player.UserId])
print (Storage:GetChildren())
print (Storage.Squat)
end
return AnimationsModule
For further context, I’m basically trying to load in Animations ahead of time since I’ve ran into a few issues, where I load the animation within the wrong scope and it’s loaded several times. This prevents me from properly manipulating the animation in the future.
The ‘Animations’ folder within my ServerStorage contained two Animation instances “Squat” and “SquatIdle”, but neither seem to pop up.
Help would be appreciated!
(If additional information is needed, ask and I will show!)
Is this module being required by a LocalScript? If so, they don’t have access to the contents of ServerStorage - they don’t replicate to the client. You’d have to use ReplicatedStorage if you wanted the program to access the animations via a LocalScript.
My script got a bunch of bugs because there’s something wrong with it, but the error I made the post for is fixed! Thank you, I didn’t know it’d be something like that!
You’re the goat bro. I’m going to write this down into one of the bugs that happen with roblox so it doesn’t happen again