PartCache, for all your quick part-creation needs

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

2 Likes

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.

3 Likes

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?

2 Likes

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

2 Likes

: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.

2 Likes

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.

2 Likes

Yes, they need to be anchored when stored.

2 Likes

Epic, thanks for that response time.

1 Like

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

1 Like

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

1 Like

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

5 Likes

Anything I can do about this?

18d4918f186babbeba7e6510f29f860c

1 Like

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?

5 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.

3 Likes

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
2 Likes

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

1 Like

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

1 Like
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

2 Likes

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
6 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?

2 Likes