Kill part not working

Hello! So, I made a very simple kill part for one of my obby stages, and for some reason, the kill part does not kill the player if they continue to jump on it. The moment the player stops jumping, the part kills them, but it seems like the touched event is not firing if they jump too much.
Here is the script:

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent:BreakJoints()
	end
end)

It’s in a mesh part.
Any help would be appreciated! Thanks!

5 Likes
script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		hit.Parent.Humanoid.Health = 0
	end
end)

Try this approach, it should handle this better.

3 Likes

I used this before, it had the same problem. The problem is not the health script, its the fact that the touched event doesn’t fire when a player jumps on the part continuously. Thanks!

This is an error found very commonly in various obby games in Roblox. I would recommend trying the Touched event of the Humanoid for this purpose.

1 Like
local function damagePlayer(otherPart)
   local partParent = otherPart.Parent
   local humanoid = partParent:FindFirstChild("Humanoid")
   if humanoid then

humanoid.Health = 0
end
end

1 Like

And disconnect the RBXSignal if Player deads, it’ll reset anyway.

1 Like

That is the same thing as before, just putting the code into a function. The problem is with the touched event not detecting like @Anurag_UdayS said. Is there any way to fix that? Thanks!

I use something like this usually, its probably overly complicated though.

local damager = script.Parent


local function damagePlayer(otherPart)
	local partParent = otherPart.Parent
	local humanoid = partParent:FindFirstChild("Humanoid")
	if humanoid then
		humanoid.Health = 0
	end
end

damager.Touched:Connect(damagePlayer)
1 Like

I recommend to index it to table.

One script all killbricks

2 Likes

Sorry, I didn’t understand what you meant by

Thanks!

I probably would do that, but that makes it more complicated and I just wanted to type something quickly

1 Like

I’ve an plan to create an obby too, maybe with my knowledge i can pull it off.

1 Like

I know but everyone has own preferences and techniques to achieve it.

1 Like

I’m really sorry @SaintlySoup and @EthanBlox_TV but the problem is not with the actual function inside of the touched event, it is that the touched event is not firing at all if the player is jumping.

local damager = -- YourPartHere
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
local HRP = Character:WaitForChild("HumanoidRootPart")
HRP.Touched:Connect(function(Hit)
if Hit == damager then
Character:WaitForChild("Humanoid").Health = 0
end
end)
end)
end)
2 Likes

Turn killbricks cancollide off and put part underneath

1 Like

Let me try that thanks! Also I’ll try your solution as well @EthanBlox_TV

Because some R15 animations don’t even touch the ground.

1 Like

I believe that animations do not influence HitBox, as they preserve the HitBox while playing. Not too sure tho.

1 Like

This works, but, it would be really time consuming to add all of my kill parts into a table as I have hundreds of them in my game. Do you have any ideas?
Edit: No, unfortunately, this doesn’t work either after I tried testing again :sad: