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)

2 comments
That seems logical but it doesn't work
Well, it does work because that's exactly what you're doing dude.