The tutorial Raycasting: Making a Laser Gun doesn’t disconnect the Mouse.Button1Down event listener, which could result in memory leaks and other potentially unexpected behaviour, mainly it will spam print the more you unequip and equip, as it’s creating new connections each time.
Also it uses deprecated terms:
.FormFactor
.unit
.magnitude
:connect
CFrame.new(pos, lookAt) constructor
And finally, it is not compatible with filtering enabled as everything is done locally.
This article was migrated from the wiki a long time ago, which is why it is so incredibly dated. In fact, I think I remember this being written when raycasting first came out. We will either be removing it or updating it shortly after the team decides if it’s worth keeping around (there are more useful applications of raycasting).
Hi all,
The old article has been totally removed due to inaccuracy and outdated practices. It has been replaced with a new “Intro to Raycasting” article and a small demo place which you can experiment with.
Hope this helps! We’ll also be exploring more advanced topics/usages of raycasting in the future, but this intro was the first priority.
Worth noting that I just updated this article (and the sample project) to use the newer WorldRoot:Raycast() function instead of Ray.new() and workspace:FindPartOnRay(). I recommend developers begin migrating over to the newer API, as it’s easier to use and returns an object that can be more easily dissected.
Thankfully! Honestly the old tutorial was easy to understand for beginners (like me in a year ago) to create basic guns but it’s lack of explanations. However without this updated version, I don’t even know the RaycastParams exists!