"Raycasting: Making a Laser Gun" potential memory leak and more

edit; just realised megathread was a thing

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.

21 Likes

I dislike this entire article. It doesn’t accurately mention how to raycast at all and is the only official tutorial for it.

6 Likes

If there is not going to be useful documentation for how to use the raycasting functions on the wiki, there should at least be an accurate tutorial on it.

1 Like

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).

2 Likes

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.

IgnisRBX

6 Likes

Well then! May that article rest in peace.

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.

2 Likes

Ooh nice. Will the old raycasting API be left as legacy or even deprecated?

man that article was really useful to me when i was a newer scripter, since i had no idea about how much outdated practices and code it had

though it was for the best i guess. rest in peace

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!

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