Basically this line of code when i fire a raycast at the sky errors with “attempt to index nil wit Instance”
if Raycast.Instance ~= nil then
MakeParticleFX(Raycast.Position, Raycast.Normal)
local Hit:Part = Raycast.Instance
local Humanoid = (Hit.Parent:FindFirstChildOfClass("Humanoid") or Hit.Parent.Parent:FindFirstChildOfClass("Humanoid"))
if Humanoid and Humanoid.Parent ~= Player.Character then
Humanoid:TakeDamage(Settings.DAMAGE)
end
end
Since you hit nothing, there is no Raycast.Instance provided, the only way to check if a Raycast hit something is to check if its not equal to nil
if Raycast ~= nil then
MakeParticleFX(Raycast.Position, Raycast.Normal)
local Hit:Part = Raycast.Instance
local Humanoid = (Hit.Parent:FindFirstChildOfClass("Humanoid") or Hit.Parent.Parent:FindFirstChildOfClass("Humanoid"))
if Humanoid and Humanoid.Parent ~= Player.Character then
Humanoid:TakeDamage(Settings.DAMAGE)
end
end