Why not collide with certain parts?

game.ReplicatedStorage.FireBall.OnServerEvent:Connect(function(plr,id)
	local char = plr.Character
	local a = Instance.new("Animation")
	a.AnimationId = "rbxassetid://"..id
	local anim = char.Humanoid:LoadAnimation(a)
	anim:Play()
	wait(anim.Length - 0.2)
	local p = Instance.new("Part",workspace)
	p.Anchored = true
	local fire = Instance.new("Fire",p)
	fire.Size = 20
	p.CanCollide = true
	p.Transparency = 1
	local v = Vector3.new(char.HumanoidRootPart.CFrame.LookVector.X,0,char.HumanoidRootPart.CFrame.LookVector.Z)
	p.Position = char.HumanoidRootPart.Position + (v*2)
	wait(0.2)
	local x = true
	coroutine.resume(coroutine.create(function()
	while x do
		wait()
		p.Position += v/7
		end
	end))
	p.Touched:Connect(function(hit)
		
		local e = Instance.new("Explosion",hit)
		e.BlastRadius = 3
			e.BlastPressure = 400
			e.Position = p.Position
			x=false
		
	end)
end)

upon shooting this into a wall it doesn’t explode but when i walk into it, it does, if anyone knows why it wont explode when hitting the wall, or why it only explodes by hitting me it would be very appreciated thanks!

1 Like

The Touched event won’t fire when two anchored parts are touching. Your character is unanchored, which is why it does fire when you touch it. If you want to detect when two anchored parts are intersecting, check p:GetTouchingParts() every frame. Note that I said intersecting. This won’t fire if the two parts’ surfaces are touching but not intersecting. I think it should still fit your use case.