It's a confusing question, I know, but I've tried to deal in raycasting (something Kenetic should add as a tag), and I've found that you can only fire at an existing brick and not the skybox, or else the script breaks. How do I do a workaround? I've tried just replacing the mouse.Hit.p with 999, but it was as if I had done nothing to it. It still broke after I shot at the skybox.
Here's my code:
function drawTrail (mag,position,ry) local trail = Instance.new ('Part', Workspace); trail.formFactor = Enum.FormFactor.Custom if mouse.Hit.p ~= nil then trail.Size = Vector3.new(0.1, 0.1, mag) trail.CFrame = CFrame.new ((script.Parent.Handle.CFrame.p + mouse.Hit.p)/2, mouse.Hit.p) else trail.Size = Vector3.new (.1,.1,999) trail.CFrame = CFrame.new ((script.Parent.Handle.CFrame.p + Vector3.new (999,999,999))/2, Vector3.new (999,999,999)) end trail.BrickColor = BrickColor.new ('Mid grey') trail.Transparency = .5 trail.Anchored = true trail.CanCollide = false trail.TopSurface = Enum.SurfaceType.Smooth trail.BottomSurface = Enum.SurfaceType.Smooth for i = .5,1,.1 do trail.Transparency = i wait (.1) end game.Debris:AddItem (trail, .1) end
I never knew that it would break if you shot at a skybox... Hm. Well, as you said "you can only fire at an existing brick". So why not just add a lining on the inside of the skybox as a loophole?
The best fix is if the raycast function doesn't return a part, that it uses the Mouse's Hit and shoot at that instead, but limited to a maximum size to reduce lag.