Hi. So im makinga gun game but theres one simple problem. Bullets themselves WILL pierce through enemies, but the damage doesnt. Can someone help me think how?
local laserFireEvent = game.ReplicatedStorage.Guns.Pistol local laserFolder = game.Workspace.Bullets local debris = game:GetService("Debris") local range = 100 local function CreateBeam(origin, direction) local midpoint = origin + direction/2 local part = Instance.new("Part") part.Parent = laserFolder part.Anchored = true part.CanCollide = false part.Material = Enum.Material.Neon part.BrickColor = BrickColor.new("New Yeller") part.Transparency = 0 part.CFrame = CFrame.new(midpoint, origin) part.Size = Vector3.new(.5, .5, direction.magnitude) debris:AddItem(part, 0.25) end laserFireEvent.OnServerEvent:Connect(function(player, mousePos, originPos) local direction = (mousePos - originPos).Unit * range local result = game.Workspace:Raycast(originPos, direction) if result then local character = result.Instance.Parent local humanoid = character:FindFirstChild("Humanoid") if humanoid and humanoid ~= player.Character.Humanoid then humanoid:TakeDamage(20) end end CreateBeam(originPos, direction) end)