Sometimes deal damage and sometimes not

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!

A gun that damaging clearly.

  1. What is the issue? Include screenshots / videos if possible!

robloxapp-20230504-0855297.wmv (1.2 MB)

When the bullet hits dummy, sometimes deal damage while sometimes not. (it deals when I move or whtever)

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

Most common thing was about :SetNetworkOwner(). I use that to make bullet travelling smooth. But it results deals damage and not deals damage. If I remove that, my bullet travelling laggy but deals damage clearly without any problems.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

bullet.Size = Vector3.new(0.2,0.2,0.2)
	bullet.Color = Color3.fromRGB(35, 35, 35)
	bullet.Shape = Enum.PartType.Ball
	bullet.CFrame = CFrame.new(Weapon.Shoot.Position, endpos)
	bullet.Anchored = false
	bullet.CanCollide = false
	bullet.Name = "Bullet"
	bullet:SetNetworkOwner(Plr)
	
	game.Debris:AddItem(bullet, 20)
		
	local antigravity = Instance.new("BodyVelocity", bullet)
	antigravity.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
	antigravity.Velocity = bullet.CFrame.LookVector * 800 + Vector3.new(math.random(-Accuracy.Value * 2, Accuracy.Value * 2), math.random(-Accuracy.Value * 2, Accuracy.Value * 2), math.random(-Accuracy.Value * 2, Accuracy.Value * 2))

	local the_creator = Instance.new("StringValue")
	the_creator.Name = "creator"
	the_creator.Parent = bullet
	the_creator.Value = Plr.Name
		
bullet.Touched:Connect(function(hit)
		local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid") or hit.Parent.Parent:FindFirstChildOfClass("Humanoid")
		if humanoid and humanoid.Parent.Name ~= bullet.creator.Value then
			humanoid:TakeDamage(math.random(MinDamage.Value,MaxDamage.Value))
			end
		bullet:Destroy()
	end)
end

I dunno how to make the bullet hits and deal damage clearly.