Weird issue with FastCast Redux

So I was creating an OTS gun system for R15 and this weird issue popped up.

Bullets that should travel after being fired don’t actually travel.

All of the bounding boxes are bullet models that never fired.

I am firing the bullets using this function here:

local cast = fastcastredux.new()

local holder_folder = workspace:FindFirstChild("CONTAINER_FASC") or Instance.new("Folder",workspace)
holder_folder.Name = "CONTAINER_FASC"

local rayp = RaycastParams.new()
rayp.FilterType = Enum.RaycastFilterType.Exclude
rayp.IgnoreWater = true

local raybehavior = fastcastredux.newBehavior()
raybehavior.Acceleration = Vector3.new(0,-(workspace.Gravity/40),0)
raybehavior.RaycastParams = rayp
raybehavior.CosmeticBulletTemplate = game:GetService("ServerStorage").gun_bullets[tool.Name]:WaitForChild("b"):Clone()
raybehavior.CosmeticBulletContainer = holder_folder
raybehavior.MaxDistance = 1000

function fireCast(cf)
	if g_settings.Ammo.Value > 0 and equipped then
		local cstorigin = tool.Handle.fire.WorldPosition
		local ndr = (cf-cstorigin).Unit
		local directionalCF = CFrame.new(Vector3.new(), ndr)

		local direction = (directionalCF * CFrame.fromOrientation(0, 0, rng:NextNumber(0, tau)) * CFrame.fromOrientation(math.rad(rng:NextNumber(-g_settings.Spread.Value,g_settings.Spread.Value)), 0, 0)).LookVector

		if ricochet then
			raybehavior.CanPierceFunction = CanRayPierce
		end
		print("firing")
		cast:Fire(cstorigin,direction,1000,raybehavior)
		print("fired")
		
		g_settings.Ammo.Value = g_settings.Ammo.Value - 1
		print(g_settings.Ammo.Value)
		local newaudio = tool.Handle.fireaud:Clone()
		newaudio.Parent = tool.Handle
		newaudio:Play()
		newaudio.Ended:Connect(function() newaudio:Destroy() end)

		for i,v in pairs(tool.Handle.fire:GetChildren()) do
			if v:IsA("ParticleEmitter") then
				v:Emit(30)
			end
		end

		tool.Handle.fire.PointLight.Enabled = true
		delay(0.05,function()
			tool.Handle.fire.PointLight.Enabled = false
		end)
	end
end

The “cf” argument is mouse.Hit.Position.

If anyone knows why this is happening, I would greatly appreciate your input.

Thank you,
-Xarciti.

2 Likes

Boosting this post since I need to have this done soon for a project I’m working on.

It looks like they are hitting the gun model. Is the player character under fastcast’s whitelist?

Looks like u didnt put anything in the filter.
should be solved with:

rayp.FilterDescendantsInstances = {parts to ignore, gun-model, etc}

I usually do this by grouping everything that bullets should ignore in a folder called Ignore.
If you use this method you can simply:

rayp.FilterDescendantsInstances = {workspace.Ignore}

Didn’t seem to work.

I had already implemented this after this post realizing it wasn’t there, I should have updated you guys.

You haven’t implemented a caster.LengthChanged function that will update the bullet position. Also, could you paste the whole code?

ok guys it turned out i just forgot to connect literally every event fastcast relies on

dont be stupid like me :stuck_out_tongue:

I would also recommend adding PartCache to it because it will perform better and FastCast already has implementation for it, you just need to add a few lines.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.