How I stop my gun bullets making ricochet

I am trying to make one weapon it works but I really hate the ricochet.
I tried to destroy it with one Touched function.

ServerScriptService (RemoteFunction)

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("ShootEvent")

RemoteEvent.OnServerEvent:Connect(function(player, gunPos, gunOr, mosPos)
	
	local bullet = ReplicatedStorage.Bullet:Clone()
	bullet.Parent = game.Workspace
	bullet.Position = gunPos
	
	local distance = (mosPos - gunPos).magnitude
	local speed = 400
	bullet.CFrame = CFrame.new(gunPos, mosPos)
	bullet.Velocity = bullet.CFrame.lookVector * speed	
	local fly = Instance.new("BodyForce",bullet)
	fly.Force = Vector3.new(0, bullet:GetMass() * workspace.Gravity, 0)
	bullet.Orientation = gunOr + Vector3.new(0, -90, 0)	
	
	local attacker = Instance.new("StringValue")
	attacker.Name = "Attacker"
	attacker.Parent = bullet
	attacker.Value = player.Name
end)

Inside the bullet (ReplicatedStorage)

local bullet = script.Parent
local headShotSound = game.Workspace:WaitForChild("HitShotSound")

local function player_check(otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
	if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
		if otherPart.Name == "Head" then
			humanoid:TakeDamage(100)
			headShotSound:Play()
		elseif otherPart.Name == "HumanoidRootPart" then
			humanoid:TakeDamage(75)
			headShotSound:Play()
		else
			humanoid:TakeDamage(30)
			headShotSound:Play()
			
		end
	end
end

local function RemoveBullet()
	bullet.Touched:Connect(function()
		game.Debris:AddItem(bullet, 0.01)
	end)
end


bullet.Touched:Connect(player_check)
bullet.Touched:Connect(RemoveBullet)

this is the script

bullet.CanCollide = false

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("ShootEvent")

RemoteEvent.OnServerEvent:Connect(function(player, gunPos, gunOr, mosPos)
	
	local bullet = ReplicatedStorage.Bullet:Clone()
	bullet.Parent = game.Workspace
	bullet.Position = gunPos
	
	local distance = (mosPos - gunPos).magnitude
	local speed = 400
	bullet.CFrame = CFrame.new(gunPos, mosPos)
    bullet.CanCollide = false -- Not 100% sure but try it
	bullet.Velocity = bullet.CFrame.lookVector * speed	
	local fly = Instance.new("BodyForce",bullet)
	fly.Force = Vector3.new(0, bullet:GetMass() * workspace.Gravity, 0)
	bullet.Orientation = gunOr + Vector3.new(0, -90, 0)	
	
	local attacker = Instance.new("StringValue")
	attacker.Name = "Attacker"
	attacker.Parent = bullet
	attacker.Value = player.Name
end)

Try merging your player_check function and RemoveBullet function into the same function. Then instead if using Debris:AddItem you should just call :Destroy() on the bullet so it is destroyed instantly instead of after a 0.01 second delay.

Also the way you have set up your RemoveBullet function is kind of wacky. Try something like this:

local Damages = {
    Head = 100,
    HumanoidRootPart = 75
}

local function HandleBulletCollision(otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")

	if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
        local Damage = Damages[otherPart.Name] or 30

        humanoid:TakeDamage(Damage)
        headShotSound:Play()
        bullet:Destroy()
    end
end

bullet.Touched:Connect(HandleBulletCollision)

The problem with ricochet its on characters and in Parts.

If I turn off canCollide the bullets will pass all walls…

destroy the bullet when it hits a wall/stop it.

I tried but doesnt work. In the 2 script I tried to make wait(0.001) and then it destroy.

Try this script inside the bullet

local bullet = script.Parent
local headShotSound = game.Workspace:WaitForChild("HitShotSound")

local function player_check(otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
	if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
		if otherPart.Name == "Head" then
			humanoid:TakeDamage(100)
			headShotSound:Play()
		elseif otherPart.Name == "HumanoidRootPart" then
			humanoid:TakeDamage(75)
			headShotSound:Play()
		else
			humanoid:TakeDamage(30)
			headShotSound:Play()
			
		end
	else
		bullet:Destroy()
	end
end

local function RemoveBullet()
	bullet.Touched:Connect(function()
		game.Debris:AddItem(bullet, 0.01)
	end)
end


bullet.Touched:Connect(player_check)
bullet.Touched:Connect(RemoveBullet)

I cant do that (This can touch in nothing and destroy())

local bullet = script.Parent
local HitSound = game.Workspace:WaitForChild("HitShotSound")

local function player_check(otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
	if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
		if otherPart.Name == "Head" then
			humanoid:TakeDamage(100)
			HitSound:Play()
		elseif otherPart.Name == "HumanoidRootPart" then
			humanoid:TakeDamage(50)
			HitSound:Play()
			bullet:Destroy()
		elseif otherPart.Name == "Left Arm" then
			humanoid:TakeDamage(30)
			HitSound:Play()
			bullet:Destroy()
		elseif otherPart.Name == "Right Arm" then
			humanoid:TakeDamage(30)
			HitSound:Play()
			bullet:Destroy()
		elseif otherPart.Name == "Left Leg" then
			humanoid:TakeDamage(30)
			HitSound:Play()
			bullet:Destroy()
		elseif otherPart.Name == "Right Leg" then
			humanoid:TakeDamage(30)
			HitSound:Play()
			bullet:Destroy()
		end
	end
end

bullet.Touched:Connect(player_check)

game.Debris:AddItem(bullet, 10)

What did you changed in this script?

Edit: I don’t see what destroys the bullet

the orginal script imagine if I put “else bullet:Destroy()” and this bullet hit one arm this dont take damage and will destroy() I changed the script again:

local bullet = script.Parent
local HitSound = game.Workspace:WaitForChild("HitShotSound")

local function player_check(otherPart)
	local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
	if humanoid and humanoid.Parent.Name ~= bullet.Attacker.Value then
		if otherPart.Name == "Head" then
			humanoid:TakeDamage(100)
			HitSound:Play()
            bullet:Destroy()
		elseif otherPart.Name == "HumanoidRootPart" then
			humanoid:TakeDamage(50)
			HitSound:Play()
			bullet:Destroy()
		elseif otherPart.Name == "Left Arm" then
			humanoid:TakeDamage(30)
			HitSound:Play()
			bullet:Destroy()
		elseif otherPart.Name == "Right Arm" then
			humanoid:TakeDamage(30)
			HitSound:Play()
			bullet:Destroy()
		elseif otherPart.Name == "Left Leg" then
			humanoid:TakeDamage(30)
			HitSound:Play()
			bullet:Destroy()
		elseif otherPart.Name == "Right Leg" then
			humanoid:TakeDamage(30)
			HitSound:Play()
			bullet:Destroy()
		else
			humanoid:TakeDamage(30)
			wait(0.2)
			bullet:Destroy()
		end
	end
end

bullet.Touched:Connect(player_check)

game.Debris:AddItem(bullet, 10)