PartCache, for all your quick part-creation needs

Cool module, any chance you would add the Luau type annotations to it?

Oh yeah! I hadn’t actually realized it was released. I can do that ASAP.

Edit: Update is out. Of course, scripts may show a number of false warnings due to type checking beta. There is now a “README” script in the module that goes over what to expect.

1 Like

I am looking through the module code but unable to figure out :exploding_head: where I change the default parent object for the cached parts.
Now they are all parented to the Workspace.
Is it possible to specify the parent object for each cache?

Look at the main post, at the bottom. There’s a ref sheet.

1 Like

:GetPart(), not .GetPart()

As for moving the part as a bullet, I wrote a module for that too, and the module actually can tie into this one. See FastCast.

1 Like

Do the parts in the cache need to be anchored? I doubt that their physics are simulated when they are so far away, but I want to make sure.

Yes, they need to be anchored when stored.

Epic, thanks for that response time.

Could you post some a script for some of us noobs :c

When moving cached parts to a position, should I use CFrame to position them or use the position property?

Sorry to put this warning here but I can’t create a new topic in Studio Bugs.

This warning comes up when I open the script for PartCache, its something about Free types.
This is the first time I have tried to use PartCache and the warning came up.
It is in the PartCache module script.

image

2 Likes

Anything I can do about this?

18d4918f186babbeba7e6510f29f860c

Please try to actually describe what’s wrong. What you’ve effectively done is sat down at a restaurant, and told the waiter “Yes, please give me some food.”

I’m going to need to know what the problem actually is if you want guidance on it. When is this happening?

2 Likes

Sorry for the late response, came here from a hyperlink.

Anyways for a solution I handled objects that aren’t necessary to the server, like bullet trails (that don’t need collision) on the client. Reduced the Network problem.

Essentially what was wrong is I was using part cache only on the server. I had to make my own for the client but it didn’t take too long thanks to you making your scripts easy to read, thank you.

1 Like

Whats happening…

local RandomPosModule = require(script.RandomPositionModule)
local PartCacheModule = require(script.Parent.PartCache)

local Droplet = game.ReplicatedStorage.RainDroplet
local ModuleRain = PartCacheModule.new(Droplet, 50)

while wait() do
	
		for i = 1,(script.Parent.Amount.Value) do
		
		local DropletClone = PartCacheModule.GetPart(ModuleRain)
		
		DropletClone.Parent = workspace
		RandomPosModule.RandomPosition(script.Parent,DropletClone)
		
	end
end

You need to return the part to the cache at some point using ReturnPart.

Oh, let me give it a try.
Thank you.

local RandomPosModule = require(script.RandomPositionModule)
local PartCacheModule = require(script.Parent.PartCache)

local Droplet = game.ReplicatedStorage.RainDroplet
local ModuleRain = PartCacheModule.new(Droplet, 50)

while wait() do

	for i = 1,(script.Parent.Amount.Value) do

		local DropletClone = PartCacheModule.GetPart(ModuleRain)

		DropletClone.Parent = workspace
		RandomPosModule.RandomPosition(script.Parent,DropletClone)
		
		ModuleRain:ReturnPart(DropletClone)
	end
end

so now theres no errors, but its not spawning. Its just staying un-used

You’re instantly returning to the cache afterwards. You’ll probably want something like this.

local RandomPosModule = require(script.RandomPositionModule)
local PartCacheModule = require(script.Parent.PartCache)

local Droplet = game.ReplicatedStorage.RainDroplet
local ModuleRain = PartCacheModule.new(Droplet, 50)

while true do
	local parts = {}
	for i = 1,(script.Parent.Amount.Value) do

		local DropletClone = PartCacheModule.GetPart(ModuleRain)

		DropletClone.Parent = workspace
		RandomPosModule.RandomPosition(script.Parent,DropletClone)
		
		table.insert(parts, DropletClone)
	end

	wait()

	for _, part in ipairs(parts) do
		ModuleRain:ReturnPart(part)
	end
end
2 Likes

It works, thanks! However, I want them to fall when they spawn there. When they touch something they go back to the cache. How can I do this?