Hello,
I am trying to stop it from erroring when it cannot find the object "Config" but I haven't been able to figure it out.
local user = tool.Parent
local ray = Ray.new(tool.MuzzleFlash.CFrame.p, (target - tool.MuzzleFlash.CFrame.p).unit*300)
local hit, position = game.Workspace:FindPartOnRay(ray, user)
local TargetObj = hit and hit.Parent.Parent:FindFirstChild("Config")
local DamageObj = TargetObj
if DamageObj then
DamageObj.Hull.Value = DamageObj.Hull.Value - 25
end
Any help would be appreciated

2 comments
try adding "if TargetObj then" and also is hit nil?
try adding "if TargetObj then" and also is hit nil?