I keep many of my assets, such as sounds, meshes, and animations in the ServerStorage so that it can be easily accessed by my server-sided scripts. I want all of these assets to be loaded for every player, but PreloadAsync is a client-sided function. Am I going to have to move all of my assets to the client in order to preload them? I'm worried about exploiters getting access to these assets if I put them in the client side. Here are my scripts: From the server:

game.Players.PlayerAdded:Connect(function(player)
    local assetsToLoad = game.ServerStorage:GetDescendants()
	game.ReplicatedStorage.LoadContent:FireClient(player, assetsToLoad)
end)

From the client:

local ContentProvider = game:GetService("ContentProvider")
game.ReplicatedStorage.LoadContent.OnClientEvent:Connect(function(assets)
	repeat wait() until script.Parent:FindFirstChild("Frame") ~= nil --Waiting for the gui to load
	assets = game.ServerStorage:GetDescendants()
	script.Parent.Frame.Visible = true
	for num, asset in pairs(assets) do
		script.Parent.Frame.TextLabel.Text = num .. "/" .. #assets
		ContentProvider:PreloadAsync({asset})
	end
	for i = 0, 1, .1 do
		script.Parent.Frame.BackgroundTransparency = i
		script.Parent.Frame.TextLabel.TextTransparency = i
		wait()
	end
	script.Parent.Frame.Visible = false
end)

4 comments

0

i am not familiar with PreloadAsync but if you load it in the client, then destroy the item as soon at it is loaded, will that work? Or can exploiters use that loaded copy?

0

An interesting idea, but I have a lot of assets in my game. It may take time to load them all before they're deleted, giving exploiters some extra time...

0

If your assets end up being used by the client anyway, why the worry about exploits during preload?

0

The assets will only be used by server-sided scripts, I'm just trying to preload them