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)

3 comments
Try setting the beam non-collidable.
what do you mean?
Assuming the beam has a transparency, you could try putting glass over the area (albeit, cancollide = false) where you don't want the ray to be seen (this is only applicable if you want the ray to not be seen ever in that area)