I have been using fasstcast for a short time I tried make a pierce function but for some reason it would not go through and it prints true. Any help would be great
local caster = FastCast.new()
local castParams = RaycastParams.new()
castParams.FilterType = Enum.RaycastFilterType.Blacklist
local newBullet = Instance.new("Part", Folder)
newBullet.Size = Vector3.new(0.1, 0.1, 1)
newBullet.Material = Enum.Material.Neon
newBullet.Shape = Enum.PartType.Block
newBullet.CanCollide = false
newBullet.Anchored = true
newBullet.Color = Color3.fromRGB(209, 130, 6)
local function Pierce(cast, result)
local Pierce_able = false
if result and result.Instance then
if result.Instance.Transparency >= .25 then
Pierce_able = true
else
Pierce_able = false
end
return Pierce_able
end
end
local castBehavior = caster.newBehavior()
castBehavior.RaycastParams = castParams
castBehavior.Acceleration = Vector3.new(0,(-workspace.Gravity/2)+ (BulletDrop),0)
castBehavior.CosmeticBulletContainer = Folder
castBehavior.CosmeticBulletTemplate = newBullet
castBehavior.CanPierceFunction = nil
castBehavior.MaxDistance = 100
local function OnLengthChanged(cast, lastPoint, direction, length, velocity, bullet)
if bullet then
local bulletLength = bullet.Size.Z/2
local offset = CFrame.new(0,0, -(length - bulletLength))
bullet.CFrame = CFrame.lookAt(lastPoint, lastPoint + direction):ToWorldSpace(offset)
Debris:AddItem(bullet, .5)
end
end
local function OnRayHit(cast, result, velocity, bullet)
local hit = result.Instance
local ECharacter = hit.Parent
if ECharacter and ECharacter:FindFirstChildWhichIsA("Humanoid")and hit:IsA("BasePart") then
Debris:AddItem(bullet, .01)
local Humanoid = ECharacter:FindFirstChildWhichIsA("Humanoid")
if not game.Players:GetPlayerFromCharacter(ECharacter) then
Humanoid:TakeDamage(BulletDamage)
end
elseif not ECharacter:FindFirstChildWhichIsA("Humanoid") and hit:IsA("BasePart") then
local HitPierce = Pierce(cast, result, velocity)
print(HitPierce)
end
end
Event.OnServerEvent:Connect(function(player, mouseP)
if player == game.Players:GetPlayerFromCharacter(Tool.Parent) then
local Character = player.Character
local RNG = Random.new()
castParams.FilterDescendantsInstances = {Character, Tool, Folder}
castParams.IgnoreWater = false
Raycast_Params.FilterDescendantsInstances = {workspace}
Raycast_Params.FilterType = Enum.RaycastFilterType.Blacklist
spawn(function()
for i = pelletsShot, maxpellets do
local origin = Tip.CFrame.p
local length = 100
local UnitDirection = (mouseP - origin).Unit
local pelletSpread = Vector3.new(RNG:NextNumber(-maximumOffset, maximumOffset), RNG:NextNumber(-maximumOffset, maximumOffset), 0)
local NewDirection = (UnitDirection + pelletSpread) * length
local Laser = workspace:Raycast(origin, NewDirection, Raycast_Params)
if Laser then
else
Laser = {}
Laser.Position = origin + NewDirection
end
local direction = (Laser.Position - origin).Unit
caster:Fire(origin, direction, BulletSpeed, castBehavior)
end
end)
end
end)
caster.LengthChanged:Connect(OnLengthChanged)
caster.RayHit:Connect(OnRayHit)