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!
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!
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)
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)
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