How to fire Touched event even when jumping on part?

  1. What do you want to achieve? Keep it simple and clear!
    An part that “kills” you if you touch it.

  2. What is the issue? Include screenshots / videos if possible!
    You can bypass this by jumping on the part:

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Using the Touched event, but you can bypass that with jumping.

This is the code I use to “kill” the player

local module = require(game.ServerScriptService.PlayerRevivalScript.Module)

local debounce = false

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		if debounce == false then
			debounce = true
			-- The next line basically "kills" the player
			module.reset(game.Players:FindFirstChild(hit.Parent.Name))
			wait(.25)
			debounce = false
		end
	end
end)

EDIT: Here’s the relevant part of the module

local module = {}

function module.teleportToCheckpoint(plr)
	plr.Character:WaitForChild("HumanoidRootPart")
	plr.Character.HumanoidRootPart.Position = plr:FindFirstChild("vars").lastCheckpoint.Value.Position + Vector3.new(0, 8, 0)
end

--[[ The only relevant part in module.reset(plr) is it calling
the module.teleportToCheckpoint(plr) function,
so I'm leaving module.reset(plr) out ]]--

return module
1 Like

Would you be able to provide the code for the modulescript, there isn’t much to work with here and im pretty sure the event is firing regardless.

1 Like

Do you mean that you can survive the kill bricks by holding the jump button?

The solution is to turn off CanCollide on the kill bricks. The default character controller has a bug where it can jump before landing instead of after landing. It’s been like this for as long as I can remember.

If you don’t think having CanCollide off looks right, you can make invisible kill bricks w/o CanCollide that surround your “visual” kill bricks but are a little bit taller.

2 Likes

Yes, yes I do mean that. I’ll see if that solution helps.

1 Like

Mm I don’t recommend using this since there is quite a big change it’ll be “fixed” later.
Instead you can probably use a humanoid.jumped:wait() event to check if the player jumped right after

1 Like

Yep this problem has happened before, I believe the cause is due to the R15 rig hit boxes as shown in the post image. Here is the post:

1 Like

This worked for the most part, but sometimes you can still bypass it by holding the jump button.

1 Like

It’s been like this for as long as I can remember, even way before R15 came out. But it may have gotten worse with R15.

A different (and IMO better) thing you can try is to weld an invisible, massless, non-cancollide part to the HumanoidRootPart just under where the character’s feet are, and use that as a additional detector to see when they land on something.

You can do that like so:
function give_character_foot_hitbox(character)
	--Remove old foot hitboxes so characters don't end up with more than 1
	remove_character_foot_hitbox(character)
	
	--Setup a new foot hitbox	
	local root_rig_att = character:FindFirstChild("RootRigAttachment", true)
	local hitbox = script.FootHitbox:Clone()
	hitbox.CFrame = root_rig_att.WorldCFrame * CFrame.new(0, -character.Humanoid.HipHeight, 0)
	hitbox.Weld.Part1 = character.PrimaryPart
	hitbox.Parent = character
end

function remove_character_foot_hitbox(character)
	local hitbox = character:FindFirstChild("FootHitbox")
	if hitbox then
		hitbox:Destroy()
	end
end

script.GiveFootHitbox.Event:Connect(give_character_foot_hitbox)
script.RemoveFootHitbox.Event:Connect(remove_character_foot_hitbox)

Here’s a place file that uses this so you can test it out: FootHitboxTest.rbxl (27.4 KB)

2 Likes