Making a shield barrier kind of thing, and I’m trying to make it take damage from gunshots and disappear once health is low. I set it up so guns can detect it through Hit.Parent.Humanoid:TakeDamage(), the only problem I’m having now is that gunshots won’t detect the part, but it detects other parts.
I had it print the parts name on .Touched, and every other part except the shield part is detected. There are no errors in the output, CanTouch is on, I have no idea what I’m doing wrong. I had set the part’s transparency to .5 to see the box more clearly and made it bigger, still no luck.
Seat.Shot.OnServerEvent:Connect(function(Player, MouseHit)
if script.Parent.Barrel.Configuration.Ammo.Value > 0 then
script.Parent.Barrel.Configuration.Ammo.Value -= 1
local RayCast = Ray.new(script.Parent.BarrelFront.CFrame.Position, (MouseHit - script.Parent.BarrelFront.CFrame.Position).unit * 2040)
local Hit, Position = workspace:FindPartOnRayWithIgnoreList(RayCast, RayCastIgnoreList)
local Dist = (Position - script.Parent.BarrelFront.CFrame.Position).Magnitude
local rayPart = Instance.new("Part", workspace)
rayPart.Name = "RayPart" rayPart.Material = BulletConfig.Material rayPart.Transparency = BulletConfig.Transparency rayPart.Color = BulletConfig.Color rayPart.Anchored = true rayPart.CanCollide = false rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(BulletConfig.Thickness, BulletConfig.Thickness, Dist) rayPart.CFrame = CFrame.new(Position, script.Parent.BarrelFront.CFrame.Position) * CFrame.new(0, 0, -Dist / 2)
rayPart.Touched:Connect(function(Hit)
if Hit ~= nil then
print(Hit.Name)
if Hit.Parent:FindFirstChild("Humanoid") then
print("Hit for (" .. BulletConfig.Damage .. ") Damage")
Hit.Parent.Humanoid:TakeDamage(BulletConfig.Damage)
elseif Hit.Parent.Parent:FindFirstChild("Humanoid") then
print("Hit for (" .. BulletConfig.Damage .. ") Damage")
Hit.Parent.Parent.Humanoid:TakeDamage(BulletConfig.Damage)
end
end
end)
TweenService:Create(rayPart, TweenInfo.new(BulletConfig.DissipateTime), {Transparency = 1}):Play()
spawn(function()
local Sound = script.Parent.Barrel.Fire:Clone()
Sound.Parent = script.Parent.Barrel
Sound:Play()
Sound.PlaybackSpeed = Random.new():NextNumber(.95, 1.1)
game.Debris:AddItem(Sound, Sound.TimeLength)
end)
game.Debris:AddItem(rayPart, BulletConfig.DissipateTime)
script.Parent.Barrel.PointLight.Enabled = true
script.Parent.Barrel.Beam.Enabled = true
wait()
script.Parent.Barrel.Beam.Enabled = false
script.Parent.Barrel.PointLight.Enabled = false
else
script.Parent.Barrel.Empty:Play()
end
end)
The Part’s name is “PBSTShieldHitPart”. No Print in the output.

