So I'm making a gun where the trail shows where the player shot, but the issue is that it goes through the object/walls and it can be seen on the other side. How can I make the trail decrease its 'Z Size' as if its going through the wall but its really just decreasing its Z size?
local ray = Ray.new(FakeTip.CFrame.p, (MousePos - FakeTip.CFrame.p).unit*Range) local Part, Pos = game.Workspace:FindPartOnRayWithIgnoreList(ray, {Char, Tool, FakeHandle, FakeTip}) local HumanoidCheck = FindHuman(Part) local Beam = Instance.new('Part') local Beam_Mesh = Instance.new('SpecialMesh') Beam_Mesh.MeshType = Enum.MeshType.Sphere Beam_Mesh.Scale = Vector3.new(1, 2, 1) Beam.Material = Enum.Material.Neon Beam.BrickColor = BrickColor.new('Daisy orange') Beam.CanCollide = false Beam.Anchored = true Beam.Size = Vector3.new(.2, .2, (FakeTip.CFrame.p - Pos).magnitude) Beam.CFrame = CFrame.new(FakeTip.CFrame.p, Pos) * CFrame.new(0, 0, -((FakeTip.CFrame.p - Pos).magnitude)/2) Beam_Mesh.Parent = Beam Beam.Parent = workspace local TrailSpeed = 15 -- 15 local Mag = (FakeTip.CFrame.p - Pos).magnitude local ZDelta = Mag/100
Here's what I mean, Below
spawn(function() for i = 0, 1, .1 do Beam.Transparency = i+.15 Beam_Mesh.Scale = Vector3.new(Beam_Mesh.Scale.X *.8, Beam_Mesh.Scale.Y *.85, Beam_Mesh.Scale.Z *1.02) Beam.CFrame = Beam.CFrame*CFrame.new(0, 0, -Beam.Size.Z*Mag/100) wait(.05) end end)