why does my bullet penetrate on the the specific target?
local tool = script.Parent
local laserFireEvent = tool:WaitForChild("LaserFire")
local laserFolder = game.Workspace.Lasers
local range = 50
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.8
part.CFrame = CFrame.new(midpoint, origin)
part.Size = Vector3.new(.1, .1, direction.magnitude)
wait(2)
part:Destroy()
end
laserFireEvent.OnServerEvent:Connect(function(player, mousePos, originPos)
local direction = (mousePos - originPos).Unit * range
local result = 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(100)
end
end
CreateBeam(originPos, direction)
end)