No Raycast Beam in Sky

I want my Raycast Beam to detect nil objects instead of detecting non nil objects only.
Right now the beam only appears when the ray hits parts, but when it hits the sky nothing appears.
How can I make it so it also appears in the sky?

I’ve looked around on the forum but nothing answers my question.

This is my code:

local bullet_hole = ss.Hole:Clone()
local bullet = ss.Bullet:Clone()
local beam = ss.GunVFX:WaitForChild("Beam"):Clone()
local shootPart = a.Handle.Muzzle

local shootPartPos = shootPart.WorldPosition
local ignoreList = {char,bullet_hole,bullet}
local params = RaycastParams.new()
params.FilterDescendantsInstances = ignoreList
params.FilterType = Enum.RaycastFilterType.Blacklist

local spread = a.Info.Spread.Value / 70 * (humrp.Velocity).Magnitude + 0.25
local dir = RandomVectorOffset((b.p - shootPartPos).Unit, math.rad(spread))

local ray = Ray.new(shootPartPos, dir * a.Info.Range.Value)
local part, pos, normal = game.Workspace:FindPartOnRayWithIgnoreList(ray,ignoreList,false,true)
local distance = (shootPartPos-pos).Magnitude
				
coroutine.wrap(function()
	for i = 0, 1, 0.2 do
		beam.Transparency = NumberSequence.new(i,1)
		wait()
	end
	beam:Destroy()
	bullet:Destroy()
end)()
				
bullet.CFrame = CFrame.new(shootPartPos)
bullet.Parent = game.Workspace
				
beam.Attachment0 = bullet.Attachment
beam.Attachment1 = bullet_hole.Attachment
beam.Parent = bullet
				
local firePitches = {
	1.1,
	1,
	0.95,
	0.975,
	1.15,
	1.2
}

bullet_hole.Parent = game.Workspace
bullet_hole.CFrame = CFrame.new(pos,pos+normal)

1 Like

That’s a lot of deprecated things you’re using, but still.

you should be able to check with an If part then else end

1 Like

Why not just put Transparent Parts surrounding your game baseplates? The ray would hit those.

They can still have a default distance for the beam in case nothing is hit, your solution sounds like it could cause technical debt, IMO.

No this is not the solution actually

Did you try @shutz’s suggestion at all?

If raycast hits part then
    fire beam at Part
else
    fire beam in direction of raycast for 200 (or so) studs
end
2 Likes

Thank you! I’m sure this would work

1 Like

You should mark @ShutzCh’s post as the solution. I just added words to it.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.