How do I fix When player jump on a killbrick that is suppose to kill you?

Im trying to make an obby but players can simply jump on killbricks to avoid damage how do I fix this?

My script:
script.Parent.Touched:Connect(function(hit)
if hit.Parent and hit.Parent and hit.Parent:FindFirstChild(“Humanoid”) then
hit.Parent.Humanoid.Health = 0
end
end)

If you use R15, the Hit Detection via the Touched Event can have some extremely wonky effects

It could be possible that if you have a lot of Parts in the game, it could create some Event delay but I don’t think that’d be the case

Your script overall seems fine, so it might just be a performance issue you could be dealing with?

What you can try doing is creating a part acting as a hitbox on the player’s feet. Modify the C0 if the box isn’t low enough. Add this script to ServerScriptService. Hope it helps!

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
	local torso = char:WaitForChild("HumanoidRootPart")
	local newPart = Instance.new("Part", char)
	newPart.Massless = true
	newPart.CanCollide = false
	newPart.Anchored = false
	newPart.Name = 'Hitbox'
	newPart.Transparency = 1

	local weld = Instance.new("Motor6D", torso)
	weld.C0 = CFrame.new(0, -3, 0)
	weld.C1 = CFrame.new()
	weld.Part0 = torso
	weld.Part1 = newPart
end)

use a script and not local script

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

or

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

The touched event might be detecting an accessory, and it can possibly ignore the event, as it won’t detect the humanoid. I have a simple function for this, I’ll be sending in a while if that’s the problem.

It doesn’t matter whether it is a local script or script, the issue is because of the player animations, the player’s feet never actually end up touching the ground when continuously jumping. When the players hits the ground, it lifts its feet up in the same frame before touched events have a chance to fire. Use the script I posted above.

Most of the time the .Touched event doesn’t work all the time unless can collide on the part is turned to false.

Yes, but sometimes people want the killbrick to have CanCollide set to true. I have wanted the terrain to kill players in the past, but obviously you don’t really want to set CanCollide to false, so just create a part acting as a hitbox.

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
	local torso = char:WaitForChild("HumanoidRootPart")
	local newPart = Instance.new("Part", char)
	newPart.Massless = true
	newPart.CanCollide = false
	newPart.Anchored = false
	newPart.Name = 'Hitbox'
	newPart.Transparency = 1

	local weld = Instance.new("Motor6D", torso)
	weld.C0 = CFrame.new(0, -3, 0)
	weld.C1 = CFrame.new()
	weld.Part0 = torso
	weld.Part1 = newPart
end)

There is always a delay, at least for R15 I believe. However, most use the .Touched event and yet they don’t face any problems with it, if they’re using the flying animation for example, it’ll be kinda hard to detect. I would recommend Region3 too. Anyways, here’s my function:

local function FindHumanoid(part)
	if not part or part == workspace or part.Parent == workspace or not part.Parent then
		return nil
	end

	local hit = part.Parent

	if hit:FindFirstChild("Humanoid") then
		return hit:FindFirstChild("Humanoid")
	else
		return FindHumanoid(hit)
	end
end

script.Parent.Touched:Connect(function(hit)
	local human = FindHumanoid(hit)
	if human and human.Health > 0 then
		human:TakeDamage(human.MaxHealth)
	end
end)

This is a good idea however it uses lots of resources I would suggest using region 3 or something like that.

It’s very low cost though… I don’t see how a single part per player uses resources. :stuck_out_tongue:

Is it a local script or a script and where did you put it

This won’t work since the problem is with the Touched event not firing…

You can make an invisible part slightly on top with Cancollide off with the kill script in it or just turn off the KillBrick’s cancollide.

here are two simple solutions

Solution 1(CanCollide set to false)

solution 1 is if you want the CanCollide disabled

step 1. make your kill brick CanCollide set to false
step 2. make your kill brick CanTouch set to true
step 3. add a simple death script to the kill brick with debounce

Solution 1 example

Action 7-12-2021 4-17-27 PM

Solution 2(CanCollide set to true)

solution 2 is if you want the CanCollide enabled

step 1. create a part in top of your kill brick
step 2. make your kill brick CanCollide set to true
step 3. make the part on top of the kill brick CanCollide set to false
step 4. make the part on top of the kill brick CanTouch set to true
step 5. add a simple death script to the part on top of the kill brick with debounce

Solution 2 example

Action 7-12-2021 4-19-27 PM

I hope I was at least some sort of help, this method is very great and works for me every time
I usually do solution 1, that is what I personally like better

Thanks to everybody who help me and now I can finally make an obby with no cheats

just put this script in the model and the model rename it (lava) so that what touches it dies (works for lava floors the same)

local lava = script.Parent

local function killPlayer(otherPart)
local partParent = otherPart.Parent
local humanoid = partParent:FindFirstChild(“Humanoid”)
if humanoid then
humanoid.Health = 0
end
end

lava.Touched:Connect(killPlayer)