Removal of the Making a Lazer Gun tutorial on Developer Hub

I wanted to make a raycast to mouse, but as usual, I forget how to get the direction to the mouse, so i went to my usual bookmark of the guide making a laser gun, but it redirected me to a different guide that doesn’t show how to raycast to the mouse. So I went and looked it up to find another source, but the only thing i found was this:

local ray = Ray.new(point,((mouse - point).unit * 300))

Yet that produces weird results when close to an object as shown:

It saddens me such a good long guide that helped me so many times was replaced by something that doesn’t really help me too much.
Any help is appreciated.

4 Likes

Did u Ignore any objects when raycasting? Sometimes the ray does that when it Ignores parts.

2 Likes

I’m ignoring a handful of parts. Any workarounds?

I miss this tutorial so much, it was VERY helpful with understanding raycasts and the newer “tutorial” does not give me as much insight as the old tutorial did.

2 Likes

Roblox good at getting rid of good things

1 Like

Is it necessary to have all these parts ignored?

Well, yes, I don’t want the bullet colliding with the gun or hats protecting players from shots

Thats fine but do u have the ground ignored?

Of course not,that wouldn’t make much sense.

Could you post your ignore list? I just want to see if that is whats causing the problem

			local ignorelist = {}
			for i,v in pairs(char:GetDescendants())do
				if v:IsA("MeshPart") then
					table.insert(ignorelist,v)
				elseif v:IsA("Part") then
					table.insert(ignorelist,v)
				end
			end
			for i,v in pairs(game.Workspace.Trash:GetChildren())do
				table.insert(ignorelist,v)
			end
			for i,b in pairs(game.Players:GetPlayers())do
				for i,v in pairs(b.Character:GetDescendants())do
					if v.Parent:IsA("Tool") then
						table.insert(ignorelist,v)
					end
					if v:IsA("Accessory")then
						table.insert(ignorelist,v)
					end
				end
			end

Heres the section of code that handles the ignorelist.

Ignorelist ignores the descendants already, you dont need to loop through descendants. What is trash?

Trash is bulletholes , tracers, etc.

If I understand correct, you’re trying to cast a ray from the mouse’s origin to the mouse’s position in 3d space, you could use Mouse.Origin and mouse.Hit.P for that.


It used archaic practices- didn’t utilize remote events for example and that’s the reason it was updated, to employ better practice and teach it to newer developers.

Im doing the ray from the front of a gun to the mouse position

I would enjoy an archive, I don’t see why not.

Didn’t read through your entire post, I am using mouse.hit.p.