Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

RayCast against the sky?

I am experimenting with raycasting guns but I am currently stuck. Whenever I try to shot at the sky nothing happens, is there something special with raycasting I have to do?

Here is everything that has to do with raycasting,

    local ray = Ray.new(
            handle.CFrame.p, --origin
           (((mouse.Hit.p - handle.CFrame.p).unit * 300) + (Vector3.new(math.random(-spreadX, spreadX),math.random(-spreadY, spreadY), 0))) --direction
        )
        local hit, position = workspace:FindPartOnRay(ray, character)

        clip.Value = clip.Value - 1

if not hit then
	return false	
end
------------------
local distance = (handle.CFrame.p - position).magnitude
bullet.Size = Vector3.new(0.2,0.2,distance)
bullet.CFrame = CFrame.new(handle.CFrame.p,position) * CFrame.new(0,0, -distance / 2)

1 answer

You're returning if you hit nothing. If you shoot the sky, you hit nothing.

2 comments

0

That seems logical but it doesn't work

0

Well, it does work because that's exactly what you're doing dude.

This discussion is preserved as it was. New answers, comments, and votes are closed.