Gun not working

Tried to create a gun script, for some reason this line in the code is an error. Dunno why, I checked the output and this popped up, I don’t exactly know what it means though.

Screenshot_476

Here’s the code:

script.Parent.Fire.OnServerEvent:Connect(function(player, mousePos)

local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = (player.Character)
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist

local raycastResult = workspace:Raycast(script.Parent.Handle.Position, (mousePos - script.Parent.Handle.Position)*300, raycastParams)

if raycastResult then
local hitpart = raycastResult.Instance

  local model = hitpart:FindFirstAncestorOfClass("Model")
  
  if model then
  	if model:FindFirstChild("Humanoid") then				
  		model.Humanoid.Health - 30 --here is the error line
  		
  	end
  end

end
end)

model.Humanoid.Health =- 30

or

model.Humanoid.Health = model.Humanoid.Health - 30

tried both of those, didn’t work, this popped up in the output
Screenshot_477

Can you replace the damage with a print the health please

Maybe its the if model then statements. Try replace the if statements and the model variable with this:

if hitpart.Parent:FindFirstChild("Humanoid") then
    hitpart.Parent.Humanoid.Health -= 30
end

Screenshot_477

did that, still same thing, Screenshot_477

Use your default code, but add .Value to the end of the problem line, so it will look like:

  local model = hitpart:FindFirstAncestorOfClass("Model")
  
  if model then
  	if model:FindFirstChild("Humanoid") then				
  		model.Humanoid.Health.Value - 30 --here is the error line
  		
  	end
  end