Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

KillBrick doesn't work if you stay jumping?

My killbrick script doesn't work unless you stand on it for a moment- I'm new to scripting so any help would be appreciated.

Heres the script.

function onTouched(Obj)
	local h = Obj.Parent:FindFirstChild("Humanoid")
	if h then
		h.Health = 0
	end
end

script.Parent.Touched:Connect(onTouched)

3 comments

0

Try printing obj, does it detect the hit?

0

This is not related to your question but try making the code more concise. Do script.parent.parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then end end)

0

Sorry for the late reply, but the solution was changing my game to R6!

2 answers

✓ Accepted answer

Is your game using R15? Try changing to R6 or change your killbrick CanCollide property to false. You can also create a hitbox and connect an event that detects if the hitbox is touched by a killbrick (or vice versa), then kills the player.

This is pretty much common, as I acknowledged character's collision on parts are quite aching to work with, especially on character models with precise collision checks.

Here is how I make kill bricks. The script should be located in the part, and be a normal script. (not local script)

script.Parent.Touched:Connect(function(hit)
    local Hum = hit.Parent:FindFirstChild("Humanoid")
	Hum.Health = 0
-- As said in the comments, print the part that is hit like this:
    print(hit.Name)
-- If it doesn't work, something is broken.
end)

There can be errors in the scripts, but if it works, it works. Also, the reason you have to wait a bit before you die is because the script has to first read the whole function, instead of instantly being fired whatever code is given. Thats the difference, if you understand what I mean.

This discussion is preserved as it was. New answers, comments, and votes are closed.