Raycasting help

I’m working on a lightning-throwing ray cast, it’s working but not really how I want it to.

I want the lightning bolt (the object I am throwing) to go exactly where my mouse is.
This is what it does;


This is the code that I am using for the ray cast;

1 Like

PFFFFT

Ok the rapid lightning strikes threw me off

Shouldn’t you be using the workspace:Raycast function instead? I mean what you’re using is fine, but it is deprecated so I do recommend changing that

For your Mouse Positioning, maybe try removing the LookVector?

3 Likes

Use units instead of lookvector, use a remote event and send the mouse’s position.

1 Like

why using math.floor on distance?

cause the distance had decimals in it

that matters because every distance has decimals

What’s wrong with me using math.floor on the distance?

it wont give the abosulute distance like if i shoot something in a wall with mouse hit and its origin it will give this distance stud for example: 45.90 so it will be exactly stop in the wall if i do math.floor it will remove its decimal thus it wont exactly stop in the wall correctly