I decided to do a check on every service to test whether or not it’ll fail outside of Workspace.
[""] = "OK",
["AnalyticsService"] = "OK",
["AnimationClipProvider"] = "OK",
["AssetService"] = "OK",
["BadgeService"] = "OK",
["BrowserService"] = "OK",
["ChangeHistoryService"] = "OK",
["Chat"] = "OK",
["CollectionService"] = "OK",
["ContentProvider"] = "OK",
["ContextActionService"] = "OK",
["ControllerService"] = "OK",
["CookiesService"] = "OK",
["CoreGui"] = "OK",
["DataStoreService"] = "OK",
["Debris"] = "OK",
["DebuggerManager"] = "Only ScriptDebuggers can be children of DebuggerManager",
["DraftsService"] = "OK",
["DraggerService"] = "OK",
["FriendService"] = "OK",
["GamePassService"] = "OK",
["GamepadService"] = "OK",
["GeometryService"] = "OK",
["GroupService"] = "OK",
["GuiService"] = "OK",
["HSRDataContentProvider"] = "OK",
["HapticService"] = "OK",
["HeightmapImporterService"] = "OK",
["HttpRbxApiService"] = "OK",
["HttpService"] = "OK",
["InsertService"] = "OK",
["JointsService"] = "OK",
["KeyboardService"] = "OK",
["KeyframeSequenceProvider"] = "OK",
["LanguageService"] = "OK",
["Lighting"] = "OK",
["LocalizationService"] = "OK",
["LogService"] = "OK",
["LuaWebService"] = "OK",
["MarketplaceService"] = "OK",
["MaterialService"] = "OK",
["MemStorageService"] = "OK",
["MeshContentProvider"] = "OK",
["MouseService"] = "OK",
["NotificationService"] = "OK",
["PackageService"] = "OK",
["PathfindingService"] = "OK",
["PermissionsService"] = "OK",
["PhysicsService"] = "OK",
["PlacesService"] = "OK",
["Players"] = "OK",
["PluginDebugService"] = "Child of PluginDebugService must be a Plugin.",
["PluginGuiService"] = "OK",
["PluginManagementService"] = "OK",
["PointsService"] = "OK",
["PolicyService"] = "OK",
["ProcessInstancePhysicsService"] = "OK",
["ProximityPromptService"] = "OK",
["PublishService"] = "OK",
["RemoteDebuggerServer"] = "OK",
["ReplicatedFirst"] = "OK",
["ReplicatedStorage"] = "OK",
["RunService"] = "OK",
["ScriptContext"] = "OK",
["ScriptEditorService"] = "OK",
["ScriptService"] = "OK",
["Selection"] = "OK",
["SelectionHighlightManager"] = "OK",
["ServerScriptService"] = "OK",
["ServerStorage"] = "OK",
["ServiceVisibilityService"] = "OK",
["SharedTableRegistry"] = "OK",
["ShorelineUpgraderService"] = "OK",
["SolidModelContentProvider"] = "OK",
["SoundService"] = "OK",
["SpawnerService"] = "OK",
["StarterGui"] = "OK",
["StarterPack"] = "OK",
["StarterPlayer"] = "OK",
["Stats"] = "OK",
["StudioService"] = "OK",
["StylingService"] = "OK",
["TeamCreateService"] = "OK",
["Teams"] = "OK",
["TeleportService"] = "OK",
["TestService"] = "OK",
["TextBoxService"] = "OK",
["TextChatService"] = "OK",
["TextService"] = "OK",
["TimerService"] = "OK",
["TouchInputService"] = "OK",
["TweenService"] = "OK",
["UGCValidationService"] = "OK",
["UserInputService"] = "OK",
["VRService"] = "OK",
["VideoCaptureService"] = "OK",
["VirtualInputManager"] = "OK",
["Workspace"] = "OK"
This list is the same when I tested on the client. Before this result I accidentally printed one without the script setting the character to the service, so it was defaulted to nil. Turns out, if the rig you want to load an animation on isn’t a descendant of Game then there’s a good chance it’ll error as a result.
To solve your problem use this code instead.
for category,value in pairs(Animations) do
if category == Subcategory then
for name,ID in pairs(value) do
local AnimID = string.gsub(ID["ID"], "%D", "")
local button = ReplicatedStorage.Extras.AnimButton:Clone()
button.Name = ID["Name"]
local PreviewAnim = Instance.new("Animation")
PreviewAnim.Name = ID["Name"]
PreviewAnim.AnimationId = "rbxassetid://"..AnimID
PreviewAnim.Parent = button
button.Parent = script.Parent.ItemLayout -- This must go first.
local Track = button.ViewportFrame.WorldModel.Dummy:WaitForChild("Humanoid"):LoadAnimation(PreviewAnim)
end
end
end
If this somehow doesn’t work, insert a task.wait()
just before the line defining Track
.