So I’m making an ability script (serverside) that deals damage (yes, I don’t want exploiters) but also playing animations… problem Animations seem to load more slower in serverscript… Is there a way to make it faster? or perhaps clientsided animation remote (Fired from server, plays the desired animation)? If that is possible, how would i create it?
1 Like
You should pre-load the animations first, before the player actually starts playing the game. Fortunately, there’s a service that allows you to do that called ContentProvider
.
One way of using this, for example in your problem, is using ContentProvider:PreloadAssets(contentIdList, callbackFunction)
. The contentIdList would be an array of Instances it used to be an array of assetId’s too, until they changed it. and the callbackFunction would be the function that gets executed after the instance’s load completes, which is optional (but it can be useful when you’re making a loading screen!!).
Here’s a code example:
-- This would be in a local script in ReplicatedFirst.
-- We would do this because it's the very first service that loads.
-- This is why, for making loading screens, they would always use ReplicatedFirst.
-- So that's also what can help you load it faster.
local ContentProvider = game:GetService("ContentProvider")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Animations = ReplicatedStorage.Animations:GetChildren() -- assuming the animations folder is ONLY animations, and creates an array for us
local startTime = os.time()
ContentProvider:PreloadAsync(Animations, function(asset)
print('Loaded in ' .. tostring(asset))
end)
local deltaTime = os.time() - startTime
print('It took ' .. deltaTime .. ' seconds to load all animations!')
10 Likes