How would I use magnitude to check if a player is near a tree for an axe script

Yeah I know what heartbeat does lmfao, it runs every frame I’m pretty sure.

1 Like

Oh ok, so whenever they click something, firing the event in this way is efficient?

Well, what I normally would do is checking if it actually something hit the ray (I believe OP uses Raycasting for their weapons), and then if it was a Tree then Fire the event, and run checks for Distance or Hit verification and stuff, which will be efficient.

It’s not a weapon lol just an ordinary axe, I kind of want to make a tree chopping system like the one found in Lumber Tycoon 2

So cast a ray where its origin is played and the ending point is Mouse.Hit.p, then when it hits something specific fire the event?

@astrozzyz If you use .Touched or Region3 For it, its pretty similar to what I suggested, so implementation will be similar.


@ItzMeZeus_IGotHacked That might actually miss a lot of points, using a good module like Raycast Hitbox which is developed for it specifically should be good to check when it hits, and then fire the event.


Anyways, as of your question, magnitude is simply length of a vector, which can be used to get distance between two points as Vector3 always has a .Magnitude property.

The module seems very complicated to use, do you have an advice about this?

Its really not complicated though, there is a piece of example code too, you can check it out. Its pretty easy to use, and provides a lot of features that many might struggle with.

Sorry had to go somewhere yesterday, I tried this and it worked for how I wanted it too, thank you