Touched Event not triggering when one part touches another

I am making an enemy that will end the game whenever it touches the character or the campfire. I detect when it touches the campfire with a simple part for a hitbox.

It detects when it touches the player just fine, but it just phases through the campfire hitbox it doesn’t even trigger the event (I’ve tried with print())

Here is a video, the hitbox is the red, slightly transparent box surrounding the campfire and the enemy is the glowing white sphere.

You may also notice that nothing is shown in the output, as you can see in the script, I have the hit’s name and parent printed when the touched event is fired.

-- follower is the enemy, which is just a sphere with stuff in it
follower.Touched:Connect(function(hit)
	print(hit.Name, hit.Parent) -- this doesn't print anything when it touches the hitbox
	local endgame = require(game.ServerScriptService.EndGameModule) -- this is the endgame function
	if game.Players:GetPlayerFromCharacter(hit.Parent) then
		endgame.Endgame()
	end
	if hit.Name == "FireBox" and hit.Parent == game.Workspace.Campfire then
		endgame.Endgame()
	end
end)

Could we see the hierarchy of the Script in the game’s Explorer?

1 Like

Screenshot 2023-07-23 175229

Currently, its in Server storage but once it spawns, I move it to Workspace, so the “Follower” part would be parented to workspace when this script runs. The script is titled “MoveScript”.

1 Like

Oh! I think I found your problem.

Basically, because the Event fires only because when Physics (e.g. Moving players count as physics) makes the parts come in contact, anchored parts don’t fire the Touched Event. A workaround for this would be to utilise GetTouchingParts, which returns a list of parts that are colliding with the mentioned part, regardless of whether the Part is anchored or not.

Read here for Touched documentation.

1 Like

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