My gun script isn't working help please

hey devs,
i’ve made a gun script but it wont function here it is:

script.Parent.fire.OnServerEvent:Connect(function(player,mousePos)
	
	local raycastParams = RaycastParams.new()
	RaycastParams.filterDecendedantsInstances = (player.Charecter)
	RaycastParams.FilterType = Enum.RaycastFilterType.Blacklist
	
	local raycastResults = workspace:Raycast(script.Parent.Handel.Position,(mousePos - script.Parent.Handle.Position)*300,RaycastParams)
	
	if raycastResults then
		local hitpart = raycastResults.Instance
		local model = hitpart:FindFirstAncestorOfClass("Model")
		
		if model then
			if model:FindFirstChild("Humanoid")
				model.Humanoid.Health -=30
			
		end
	end
end)
1 Like

this is the only one with a red line

Try getting the absolute position of your mouse, or use mouseX and mouseY.

ok ill try that now thanks :slight_smile:

thanks that worked :smiley: :+1: