Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Using Raycast to fire bullets?

Asked by 7 years ago

Hello, I'm trying to script a fire ball. I want to replace the Touched event with Raycast (this is because of the delay Touched event does)

I'm trying to make it so the Ray moves with the fire ball.

Ray gets bircks on it's way but the Hit property fires when the ball reaches that brick.

1local ray = Ray.new(Torso.CFrame.p,(Mouse.Hit.p-Torso.CFrame.p).unit*300) --- want it to make so it goes with the ball (is ball's size and moves with it)
2local Hit,pos = workspace:FindPartOnRayWithIgnoreList(ray,{player.Character,Here})
3local distance = ((player.Character.UpperTorso.CFrame).p-pos).magnitude
4 
5if (Hit) then --- fires when ball reaches the point
6    Ball:Destroy()
7end

Answer this question