Raycasting Question

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’d like to make a spell tool that uses raycasting, almost like a gun would. However, I would like to make these spells work by creating a raycast to whatever part the mouse clicks on, and if the part where they are aiming at moves after they click, the spell will move towards where that target is moving and eventually hit it.

  2. What is the issue? Include screenshots / videos if possible!
    I have no idea how I would make this work or even what to look up to find answers.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    None, seeing as I don’t know what I’m even trying to do.

1 Like

Why are you using a raycast if you know the part might move?

Use mouse.hit, store the part in a variable, then have the spell thing move to the location of the part.
Use a .changed function to check if the part moved, and if it did, have the spell thing move to the new location

2 Likes

Or you can simply just use Attachments and a LineForce

1 Like

oh damn i flipping darn forgot that existed hehe

2 Likes

The idea is that I can fetch what part the mouse clicks on by using Raycast because a gun I made before was able to return the name of the part it hit. Is there a more efficient way to get the part you click on? As for LineForce, that seems very useful and I’ll probably use that, I just need to know how to get the name of the part clicked now.

Theres no reason to specifically create a raycast. Mouse.Target (if that is the correct function) does pretty much the same thing as a raycast but it does it straight from the mouse.

1 Like

I know I marked this as the solution because when I tested 2 parts lineforces, they seemed to work how intended, however, when trying to put a lineforce on my projectile, it seems to do absolutely nothing. Here’s the code I’m using to create the lineforce. Am I missing something?
Capture

On top of this, I can see that the LineForce is being created and shows that it should be moving towards the target, it just doesn’t.

Try setting maxforce to math.Huge

1 Like

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