Render Cache is a lightweight/perfomant way to Load and Unload things from render.
It uses the same methods as PartCache or ObjectCache but in a diffrent way.
Every update happens without yielding in one frame.
There’s no need for waiting for a part to load before you can use it in the next update.
local CollectionService = game:GetService("CollectionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RenderCache = require(ReplicatedStorage:WaitForChild("RenderCache"))
local Cache = RenderCache.new()
local Parts = CollectionService:GetTagged("RenderCacher")
Cache:Register(Parts) -- Register original positions of parts
Cache:ReRegister(Parts[1]) -- Update original position of part
while true do
task.wait(1 / 10)
for i, v in pairs(Parts) do
Cache:Unload(v) --Add to parts that should unload next update
end
Cache:Update() --Update the position of parts
task.wait(1 / 10)
for i, v in pairs(Parts) do
Cache:Load(v) --Add to parts that should load next update
end
Cache:Update() --Update the position of parts
end