My ray cast script is not working and it’s giving me this error:
Players.CloutBl0x.Backpack.Revolver.GunHandler:82: attempt to index nil with 'Hit' - Server - GunHandler:82
(line 82 is the ray variable/the first line below)
Raycast Script:
local ray = Ray.new(handle.Position, (mouse.Hit.p - muzzle.Position).Unit * maxRange.Value)
local hit, pos = workspace:FindPartOnRay(ray, character)
if hit ~= nil then
if hit.Parent:FindFirstChild("Humanoid") then
hit.Parent.Humanoid:TakeDamage(math.random(damageMinMax.Value))
end
end