Script doesn't detect all Touch events?

Hi, everyone.
I am starting to make a gun script. My issue is, my script doesn’t detect when the bullet hits a wall.
However, it does detect when it hits my character. I have no idea why it does this. Anyone know why?

while true do	

	local p1 = script.Parent.Position
	local p2 = workspace.pos2.Position
	local bolt ="Part", workspace)
	bolt.Name = "bolt"
	bolt.Anchored = true
	bolt.CanCollide = false
	bolt.Material = Enum.Material.Neon
	bolt.BrickColor ="Bright blue")
	bolt.Size =, 0.075, 2.125)

	bolt.CFrame =, p2)
	local speed = (p1 - p2).magnitude / 50
	local ts = game:GetService("TweenService")
	local tween = ts:Create(bolt,, Enum.EasingStyle.Linear), {Position = workspace.pos2.Position})
		print("Hit: " .. hit.Name)
		if hit ~= script.Parent then
	spawn(function() --rid stray bullets
		if bolt then

1 Like

This is odd, please could you show me your workspace?

This way I can understand all of the parenting and help you get to the core of this issue. :smile:

This is occurring because you are tweening an anchored part to another anchored part. Touched falls under the physics pipeline and only detects for parts that intersect by cause of physics.

The player is physically simulated because they are moving and unanchored therefore the touched event will detect for them. The wall is static and everything from the wall to the bullet is anchored, so no physics are being simulated on them.

Unanchor the bullet and use a body mover (either VectorForce or BodyForce, or whatever you want so long as it’s a force).


You could also cast a ray before firing the bullet to see what it’ll hit if its not a player.

I think it should be:
if hit.Name ~= script.Parent.Name then

Perhaps you could make the Bullet use a look vector and fire it constantly so when a wall approaches it knows to disappear instead of relying on a touch script.