Touched event doesn't work if you stand still

So basically I have this kill brick that kills people at different intervals. The problem with this, is if the player stands still, they technically don’t touch it. Meaning the touch event fires, it doesn’t detect them. All help appreciated!

script.Parent.Touched:Connect(function(hit)
	if script.Parent.Electro.Enabled == true then
		if hit.Parent:FindFirstChild("Humanoid") then
			hit.Parent.Humanoid.Health = 0
		end
	end
end)

A better idea is to run a touched event on a players leg/foot and check whether it is the type of part you want to kill the player with CollectionService.

2 Likes

I have no idea what on earth collection service is. Nor do I know how to use it.

Are you making an obby where the player jumps onto the part? I don’t understand exactly what you’re trying to do… what do you mean by different intervals?

It’s a tesla gate. Basically every 2 seconds, anyone who is standing in it gets killed.

Try this:

local killPart = script.Parent
local killInterval = 2

while true do
  wait (killInterval)
  local parts = killPart:GetTouchingParts()
  for i = 1, #parts do
    local part = parts[i]
    if part.Parent:FindFirstChild("Humanoid") then
      part.Parent.Humanoid.Health = 0
    end
  end
end

It uses GetTouchingParts() instead of .Touched.

1 Like

This would only work if the gate was collideable. :GetTouchingParts() returns an empty table when CanCollide is set to false. I don’t think .Touched has this same issue.

1 Like