Need a help for making custom blacklistpart

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    i want to make custom blacklistpart based on the name of the instances for my raycast i also using fastcast to make it more smoother

  2. What is the issue? Include screenshots / videos if possible!
    the raycast ending like getting destroyed it did not really ignore the blacklistpart

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    i tried using this code

local blacklistpart = {
	["Part"] = true }
caster.RayHit:Connect(function(ActiveCast, RayResult, segmentVelocity, cosmeticBulletObject)
	if not blacklistpart[RayResult.Instance.Name] then
		local explosionsound = script.Explosion:GetChildren()
		explosionsound[math.random(1, #explosionsound)]:Play()
		local explosion = Instance.new("Explosion")

		explosion.BlastRadius = 30
		explosion.Position = RayResult.Position
		explosion.Parent = workspace
		explosion.DestroyJointRadiusPercent = 0	
		game:GetService("Debris"):AddItem(explosion, 1)
		cosmeticBulletObject:Destroy()
	end
		
end)-- i dont really want to show all the codes 

by blacklist part do you mean you want it to go through the part?

		local behaviour = fastcast.newBehavior()
		behaviour.CanPierceFunction = function(cast, result, segmentVelocity)
			if blacklistpart[result.Instance.Name] then
				return true
			else
				return false
			end
		end

add this code before you fire your caster, then when firing it, add the behaviour as an argument like this:

		caster:Fire(origin, direction, 250, behaviour)

the behaviour canpiercefunction runs before the rayhit event. it has the same argument, the difference is that you return true or false depending on if you want it to pierce through and continue. i made it so that if the part is blacklisted, then it pierces through it.

thanks for the help bro! i appreciate that

1 Like

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