How do i make the raycast bullet do damage?

Shotgun.OnServerEvent:Connect(function(Player,TargetPos,Handle,FirePart, gunType)

if gunType == "Shotgun" then
	Handle.ShotSound:Play()
	
	for i = 1,BulletsPerShot do
		local Dir = CFrame.new(FirePart.Position, TargetPos)*CFrame.Angles(math.rad(math.random(-ShotgunSpread,ShotgunSpread)),math.rad(math.random(-ShotgunSpread,ShotgunSpread)),0)
		local RayCast = Ray.new(FirePart.Position - Dir.LookVector*Range)
		local Target,Pos = game.Workspace:FindPartOnRay(RayCast,Player.Character,false,true)

		if Target then
			local Hum = Target.Parent:FindFirstChild("Humanoid")

			if Hum then
				Hum:TakeDamage(ShotgunDamage)
			end
		end

		local Vis = Instance.new("Part",game.Workspace)
		Vis.Anchored = true
		Vis.CanCollide = false
		Vis.Color = Color3.new(1,1,0)
		local Dist = (Pos - FirePart.Position).magnitude
		Vis.CFrame = Dir*CFrame.new(0,0,-Dist)
		Vis.Size = Vector3.new(0.1,0.1,Dist*2)
		game.Debris:AddItem(Vis,0.4)
	end
end

end)

bc the target part where it finds the humanoid it doesn’t work.

You should use: https://developer.roblox.com/en-us/api-reference/function/WorldRoot/Raycast

local Dir = CFrame.new(FirePart.Position, TargetPos)*CFrame.Angles(math.rad(math.random(-ShotgunSpread,ShotgunSpread)),math.rad(math.random(-ShotgunSpread,ShotgunSpread)),0)
local ray = Ray.new(FirePart.Position - Dir.LookVector*Range)
local rayParams = RaycastParams.new()
rayParams.FilterType = Enum.RaycastFilterType.Whitelist

local otherPlayers = {}
for _,p in ipairs(game.Players:GetPlayers()) do 
	if p==Player then continue 
	elseif p.Character then table.insert(otherPlayers,p.Character)
	end
end
rayParams.FilterDescendantsInstances = otherPlayers


local result = workspace:Raycast(ray.Origin,ray.Direction,rayParams)
if result then
	local Hum = result.Parent:FindFirstChild("Humanoid")

	if Hum then
		Hum:TakeDamage(ShotgunDamage)
	end
end