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.

local 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)
local Hit,pos = workspace:FindPartOnRayWithIgnoreList(ray,{player.Character,Here}) 
local distance = ((player.Character.UpperTorso.CFrame).p-pos).magnitude

if (Hit) then --- fires when ball reaches the point
    Ball:Destroy() 
end

Answer this question