Need help with FastCast Redux bullets freezing in air

so I am using a module called FastCast Redux to make a gun system and it works all good but a problem is that it seems to have an Area of effect of sorts, so the bullet will have good physics until it gets some distance away from the player in which case it will freeze in the air and not move nor despawn, I’m wondering if anyone can help me here, more info below:

Example of the problem (recorded by my friend): https://gyazo.com/68beb91693e1061a8a3fff22108890ba

The fast cast module: FastCast: Redux - Roblox
I also use the part cache module made by the same developer.

2 Likes

Did you guys modify anything about the module?
(i also use that module)

Make sure to use cast terminating to clean up the bullet, to properly despawn the bullets:

the thing is, it works alright if it hits a part or player its just if it gets too far away from the player firing the bullet its almost like it stops working, i have some ideas if they work ill update this post

no, we just use it as is but we do have a custom bullet but i doubt that is the problem.

That means the clean up is done on ray hit event,

That means the ray didn’t hit anything hence the ray hit event didn’t occur and the bullet didn’t clean up hence freeze in the air.

Consequently, this is why I suggest using the cast terminating event which accounts for both cases.

well, I already have a fix lined up but it may be a bad fix so can you tell me how i could use your way?

You get the cast object then connect this event, cannot say it will fix your problem without any reference code to look from.

local function cleanUpBullet(activeCast)
			local bullet = activeCast.RayInfo.CosmeticBulletObject
			--Debris:AddItem(bullet,1)--normal instance.new clone
			local trail = bullet:FindFirstChildWhichIsA("Trail")
			if trail then
				trail.Enabled = false
			end
			projectileCache:ReturnPart(bullet)
		end

		castComponent.CastTerminating:Connect(cleanUpBullet)
2 Likes

if all else fails ill try this

Hey so i tried your script and this is the error i get, also this is my entire script (minus the local function that activates a remote event), i also dont understand what you mean by castComponent and what that Debris is.

Script:

local Tool = script.Parent
local fireEvent = Tool:WaitForChild("FireEvent")
local FastCast = require(Tool.FastCastRedux)
local partCache = require(Tool.PartCache)

local GunData = script.Parent.GunData
local AmmoAmount = GunData:GetAttribute("AmountOfAmmo")
local GunDamage = GunData:GetAttribute("Damage")
local GunType = GunData:GetAttribute("GunType")

local BulletFolder = game.Workspace.BulletFolder
local Bullet = BulletFolder.Bullet

local caster = FastCast.new()
local castPerams = RaycastParams.new()
local CastBehavior = FastCast.newBehavior()
local bulletCache = partCache.new(Bullet, 100, BulletFolder)
CastBehavior.RaycastParams = castPerams
CastBehavior.Acceleration = Vector3.new(0, -workspace.Gravity, 0)
CastBehavior.AutoIgnoreContainer = false
CastBehavior.CosmeticBulletContainer = BulletFolder
CastBehavior.CosmeticBulletProvider = bulletCache

castPerams.FilterType = Enum.RaycastFilterType.Blacklist
castPerams.IgnoreWater = true


--------------------------------------------------------------------
local function onEquiped()
	
	castPerams.FilterDescendantsInstances = {Tool.Parent, BulletFolder}
	
end
--------------------------------------------------------------------
local function onLengthChange (cast, lastPoint, direction, length, velocity, bullet2)
	if bullet2 then
		
		local BulletLength = bullet2.Size.Z/2
		local offset = CFrame.new(0, 0, - (length - BulletLength))
		bullet2.CFrame = CFrame.lookAt(lastPoint, lastPoint + direction):ToWorldSpace(offset)
		
	end
end
--------------------------------------------------------------------
local function OnRayHit(cast, result, velocity, bullet2)
	
	local hit = result.Instance
	local character = hit:FindFirstAncestorWhichIsA("Model")
	if character and character:FindFirstChild("Humanoid") then
		
		character.Humanoid:TakeDamage(GunDamage)
		
	end
	
	delay(2, function()
		bulletCache:ReturnPart(bullet2)
	end)
end
--------------------------------------------------------------------
local function Fire(player, mousePosition)
	
	local origin = Tool.Handle.FirePoint.WorldPosition
	local direction = (mousePosition - origin).Unit
	
	
	caster:Fire(origin, direction, 1000, CastBehavior)
	
end
--------------------------------------------------------------------
local function cleanUpBullet(activeCast)
	local bullet = activeCast.RayInfo.CosmeticBulletObject
	--Debris:AddItem(bullet,1)--normal instance.new clone
	local trail = bullet:FindFirstChildWhichIsA("Trail")
	if trail then
		trail.Enabled = false
	end
	bulletCache:ReturnPart(bullet)
end
--------------------------------------------------------------------

fireEvent.OnServerEvent:Connect(Fire)
Tool.Equipped:Connect(onEquiped)
caster.LengthChanged:Connect(onLengthChange)
caster.RayHit:Connect(OnRayHit)
caster.CastTerminating:Connect(cleanUpBullet)

error:
image

Try removing this delay, I believe it’s erroring because it’s trying to return a part that’s already been returned.

On ray hit event occurs then cast terminated occurs hence the error returns the parts twice.

1 Like

yeah that worked, thanks a ton.