Roblox animations work in the game but don't load or function properly in Studio

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ContentProvider = game:GetService("ContentProvider")

local Assets = ReplicatedStorage:WaitForChild("Assets")

local function preloadFolder( folder )
	for _, child in pairs(folder:GetChildren()) do
		
		local success, ErrorMessage = pcall(function()
			ContentProvider:PreloadAsync( child:GetChildren() )
		end)
		
		if not success then
			warn("Failed to preload assets in " .. folder.Name .. ": " .. ErrorMessage)
		end
	end
end

preloadFolder(Assets.Animations)
preloadFolder(Assets.Sounds)
preloadFolder(Assets.VFX)
1 Like


Most of the animations load in studio but there is always a chunk of animations that don’t load and its usually is different animations but all these animations work in-game they all load properly in game but not studio.

You forgot to use table.insert() to insert id asset of each child in a table

ContentProvider:PreloadAsync() is need a table of asset id

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ContentProvider = game:GetService("ContentProvider")

local function PreloadFolder(Folder : Folder)
	local Content = {}
	
	for _, Asset in pairs(Folder:GetChildren()) do
		
		if Asset:IsA("Animation") then
			table.insert(Content, Asset.AnimationId)
		elseif Asset:IsA("Sound") then
			table.insert(Content, Asset.SoundId)
		end
	end
	
	local Success, ErrorMessage = pcall(function()
	ContentProvider:PreloadAsync(Content)
	end)
	
	if not Success then
		warn("Failed to preload assets in " .. Folder.Name .. ": " .. ErrorMessage)
	end
end

PreloadFolder(Assets.Animations)
PreloadFolder(Assets.Sounds)
PreloadFolder(Assets.VFX)

Didn’t fix it the animations still fail to load in studio but not ingame

1 Like

It might be a problem of Roblox Studio