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