I have made a gun, but I have a problem using it when clicking with my mouse icon on the sky. I've browsed around the internet, looked around on wiki and I know it has something to do with my mouse and I've seen people talking about mouse.Hit.p or mouse.Target but I'm using UserInputService. Does anybody know what I could of done differently that would allow me to shoot in the sky?
Here is a clip of the code I'm using for the raycast.
local RayCast = Ray.new(FP, (TP-FP).unit*100)
local Part, Position, Normal = game.Workspace:FindPartOnRay(RayCast, Player.Character, false, true)
if Part then
local Hum = Part.Parent:FindFirstChild("Humanoid")
if Hum then
Hum:TakeDamage(100)
end
local Bullet = game.ReplicatedStorage.Bullet:Clone()
Bullet.Parent = workspace
local Dist = (TP-FP).magnitude
Bullet.CFrame = CFrame.new(FP, Position)*CFrame.new(0,0, Dist/-37)
local Dist = (TP-FP).magnitude
local force = Instance.new("BodyThrust")
force.Force = Vector3.new(0, 0, -40)
force.Parent = Bullet
Bullet.Anchored = false
Bullet.Transparency = 0
wait(0.1)
force:Destroy()
wait(0.6)
Bullet:Destroy()

2 comments
I've tried putting a part way up in the sky, so it has a part to return. It still won't shoot however. Also I've noticed shooting in far ranges is a little buggy too, is there any ideal way to create a MaxDistance of the sorts?
You already have one: unit*100