Bullet Touch Not Working

Im trying to make a gun but whenever another player is moving it for some reason does not work? There are no errors btw. You can see in the output log that it is not printing “as” as when it prints it, it touches something.

Here is the bullet script:

local Bullet = script.Parent
local NearbyBulletSound = Bullet:WaitForChild('NearbyBulletSound')
local Players = game:GetService("Players")
Debris = game:GetService("Debris")

local Damage = Bullet:WaitForChild("Damage")

local Damaged = false

function TagHumanoid(humanoid, player)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.Value = player
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

function UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			v:Destroy()
		end
	end
end

Bullet.Touched:Connect(function(hit)
	print("as")
	local CharHum = hit.Parent.Humanoid

	

	if hit and CharHum and CharHum.Health > 0 and Damaged == false then

		local player = game.Players:GetPlayerByUserId(Bullet.Owner.Value)
		local hrp = player.Character:FindFirstChild("HumanoidRootPart")
		Bullet.Size += Vector3.new(player.Character.HumanoidRootPart.CFrame.LookVector)
		CharHum.Health = CharHum.Health - Damage.Value
		Damaged = true

		if CharHum.Health == 0 then
			player.folder.lastkilled.Value = hit.Parent.Name
			game.ReplicatedStorage.Killed:FireClient(player)
			NearbyBulletSound:Play()
			UntagHumanoid(CharHum)
			player.folder.killstreak.Value += 1
			TagHumanoid(CharHum, player)
		end
		
		task.wait(1)
		Damaged = false
	end
	wait(0.3)
	Bullet:Destroy()
end)

while wait(0.4) do
	
	Bullet:Destroy()
end


try raycasting instead of using a part to detect impacts

2 Likes

There are so many previous posts about why Touched isn’t great for bullets or other fast moving items.
Have a search through the forum for your title bullet touch not working. There are a lot of solved posts or others with good troubleshooting and suggestions.
You should have seen a bunch of post suggestions when you typed that title when making this post.

Can you link me to any posts?


I have read a bunch of them in the past but I can’t tell you which will work for you.
There are so many variables in the way people try to do this and the success they have. You’ll have a better idea if the posts found in your Search will help you.

Please take the time and effort to learn for yourself and not just get us to hand you information that we can only guess will be helpful in your case.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.