.Touched not working at all

Hello,
I’ve been trying to make an attack that shoots a projectile and brings you to the projectile via a BodyVelocity. When the projectile hits a wall, a large invisible part spawns on your client where the projectile hit, and when you touch it, the BodyVelocity stops.

For some reason, this invisible part doesn’t detect anything touching it. Nothing.

It’s really confusing me and I have no clue why this happens.

------- [[ Don't worry about this, it's not relevant. It just adds a BodyVelocity to your character ]] ------
	local BV = Instance.new("BodyVelocity",char.HumanoidRootPart)
	BV.MaxForce = Vector3.new(100000,100000,100000)
	BV.Velocity = CFrame.new(p.CF.Value.p, p.Position).LookVector * 340
	BV.Name = "GrappleBV"
	game.Debris:AddItem(BV,0.2)
	
	if char == plr.Character then
	local e = Instance.new("Part",workspace.Lobby)
	e.Size = Vector3.new(30,10,10)
		e.CanCollide = false
		e.Anchored = false
		e.Transparency = 0.5
		e.CanTouch = true
	e.CFrame = p.CFrame * CFrame.new(0,5,5)
	game.Debris:AddItem(e,0.6)
	local bv = Instance.new("BodyVelocity",e)
	bv.MaxForce = Vector3.new(1000000,10000000,100000000)
	bv.Velocity = Vector3.new(0,7,0)
		


----------- [[ This is the problem, it doesn't even print "e" ]] --------
		e.Touched:Connect(function(hit)
			print("e")
			if hit.Parent == char then
				if char.HumanoidRootPart:FindFirstChild("GrappleBV") then
					char.HumanoidRootPart.GrappleBV:Destroy()
				end
				
				char.HumanoidRootPart.Velocity = Vector3.new(0,0,0)
			end
		end)

Note: the code above in inside a function that’s called when the projectile hits a wall

Maybe adding the Part to debris too quickly?

Is the .Touched event inside of another event? or another function?

it’s inside a function inside a touched event

alright so turns out the script was actually being deleted before the touched event could do anything

1 Like