PartCache, for all your quick part-creation needs

It might be more performant to disable CanQuery, CanCollide, CanTouch and CastShadow for cached parts. I have not tested this, but maybe this works.

1 Like

is this better than debris service?

1 Like

Short and simple: Yes.
CFrame works best.

1 Like

Sorry for the bump, but oh wow. This module is simple yet soooo effective. It made my part rain script run waaaay much efficiently. I can now have over 300 moving rain parts on screen with maximum performance!

2 Likes

Just found this bug (it will never reach the assertwarn function call if it is == 0):


I’m trying to make it 0 parts big so it will auto fill up as needed. I don’t want to start with a value which seems sort of arbitrary. Is it better to start with a super small value and let it fill up automatically or have some random large number so you never have to worry about auto fill but possibly have excess parts. I would really prefer the former.

2 Likes

Im using CFrames to actually and FINALLY make Occlusion Culling a real thing. Initially i thought reparenting is the best option but i guess im wrong.

Now this is how it works, I’ll be using Camera: WorldToScreenPoint() to check if the player can see the parts/models or not. If they can they will stay at their original position, if not they will be CFramed away.

Thank you @Xan_TheDragon for letting me realize this as a solution.\

The problem is bringing the models/parts back, thought of replacing those with invisible parts.

2 Likes

Man I’ve been looking for this for a week only to click the link and realise I had already gotten the module. :sweat_smile:

3 Likes

Is this still the case? ||char||

So does that mean we don’t have to use PartCache because its already in the FastCast module?

I have found this error:

image

I can see that it isn’t a red underline, meaning it isn’t an error and just roblox being roblox.

1 Like

Is it possible to use this even if the bullets are all client sided? So I would have to use it on the localscript, and is it also possible if I could use it to also delete impact parts?

How does this deal with cases where a part from part cache gets destroyed, or properties of a part in the cache change? When getting that part again, it won’t be the same as the template part anymore.

1 Like

It doesn’t. If it happens to pick the altered part, then all alterations will still be there. If you destroy the part, it will not be removed (and by extension, if it is in the available list, GetPart may return the destroyed reference.)

Hello!

This is the first time im trying to use modulescripts and im having a hard time understanding how it works.

I wrote this line of code that i think should spawn a part.
local danmaku = PC:new(BType.bullet3,1,workspace.Projectiles)
But it gives an error saying that the modulescript is trying to compare a number to nil.
I’ve looked inside the modulescript and the error is caused by this line.
assert(numPrecreatedParts > 0, "PrecreatedParts can not be negative!")
I’ve tried deleting it, but it just makes a chain reaction where more and more errors appear.

Can anyone tell me what im doing wrong here?

edit:I got everthing working except for 1 part… is there any way to replicate a debris using returnpart?

That sounds like a significant problem to me.

1 Like

Heya, I have a question about the module.

Say if there are multiple players in the game and they’re all shooting at the same time, while all bullets are client-sided, do I need to create a new cache with a bunch of parts for each player or could there be another way? Thanks for reading :slight_smile:

Also I noticed that the FPS still drops even though the bullets are cached…

1 Like

Hi, I’ve been using your Module in combination with FastCast for some time now, and I’ve noticed a small problem. Sometimes, the created cosmetic parts are not deleted properly, and they keep floating in the world. This is probably due to server lag or whatever, and that’s fine. How do I remove these though? Clearing the cosmetic parts map doesn’t work properly -as it causes current used guns to not show any cosmetic bullets anymore- and I can’t use :Dispose, as the provider that was used to create them is long deleted.

So, any way to properly remove old cosmetic bullets and let new bullets be created using the MakeFromTemplate function?

I figured out how this happens btw; it’s when the entire tool (and thus script) is destroyed, but the cosmetic bullets are not removed. Any quick solution for that?

@Xan_TheDragon

I have fixed this myself for now, by firing an event every time I destroy the tool harbouring the cache. Maybe there’s an automatic way to implement this in the cache, so I’ll leave my previous comments.

1 Like

I’ve run into bug where if I shoot my bullet you can see bullet’s trail going from the sky and when the bullet lands you can also see that the trail goes into the sky
I tried enabling and disabling the trail but it didn’t give me any results :frowning:

oh and here’s my script


local function onRayHit(cast, raycastResult, segmentVelocity, bullet)
	local hitPart = raycastResult.Instance
	local hitPoint = raycastResult.Position
	local normal = raycastResult.Normal	
	

	local hit = hitPart ~= nil and hitPart.Parent ~= nil
	if hit then
		local humanoid = hitPart.Parent:FindFirstChildOfClass("Humanoid") -- Is there a humanoid?
		
		delay(.01, function()
			bullet.tracer.Parent = nil
			print("falsed yo mama")
			wait(2)
			bulletCache:ReturnPart(bullet)
		end)
	end
end

This issue is happening because the PartCache system essentially teleports parts to a very high position out of render.

To fix this, you could either:

  1. Switch from trails to beams, as they follow very similar properties, allowing you to use the same textures, attachments etc. (easy way).
  2. Go into the FastCast module itself, and find where the projectile is teleported, then enable the trail right after its teleported. You would have to also disable the trail before its teleported back to the sky. (hard way)