Nothing is working. I cannot get KILLZONE to detect if a part from a character. I've actually tried everything I can think of [SOLVED]

  1. What do I want to achieve?

I want a Moving, Non-Colliding KILLZONE to detect if a part from a character is touching it. If a part IS touching it, and it belongs to a Character, the Humanoid’s health gets set to 0. Simple, right? Well, not exactly. I only want the player to die at a specific time. The image below is a visual example.

2. What is the issue?

When I attempt to detect parts, such as using workspace:GetPartsInPart(KILLZONE), nothing to do with a character or anything. Even the Character parts with CanCollide on aren’t detected. It’s almost as if the character doesn’t exist. To make matters worse for people trying to come up with solutions, no, there are no LocalScripts involved with this. One last thing to mention is the fact that with each solution, there was a print function, that prints either a table, or "yaya "

  1. What solutions have I tried so far?
    The solutions that weren’t first attempt were google/devforum searches.

Using workspace:GetPartsInPart(KILLZONE), nothing to do with Character parts shows up, instead, it detects stuff like rooves. If I were to ask it to print a table, it would probably print something like {Roof, Floor, Light}. Below is a visual example of this. square_neutral

Among one of the first solutions I actually tried was, you guessed it, KILLZONE:GetTouchingParts(), but of course, since the KILLZONE part is Non-Collidable, It detects absolute zero. square_outline

The last solution I tried, was attempting to utilize the .Touched function, but just like the ;GetTouchingParts solution that I tried, absolutely nothing was printed. Nothing. And before you ask, no, there is no condition for this printing function, it is the first line after the Touch function is fired. square_outline

It is absolutely essential that I figure out how to make a player get killed on command by a moving KILLZONE. If this feature is not there, the game would not be the same. square_rage


I’m sorry if you have already tried this but I’m trying to fill time in before dinner, have you tried using KILLZONE.Touched()
(im on mobile rn and cant do syntax)

You could check if the part’s parent (the part that touched the kill zone) has a humanoid and then you will get only the part of the player character

as long as .CanTouch is set to true this code should work. (Script is located inside the zone part)

	plr.Parent:FindFirstChild("Humanoid").Health = 0

If you wanted to avoid all of the coding you could use the Zone+ plugin, it’s fast efficient and precise.

1 Like

I forgot to mention that I have a print function inside an if statement that essentially asks exactly that, it prints yaya2, and even that hasn’t been printed once.

For all I know, .CanTouch IS set to true, and the code still doesn’t work. :cry:

where is the script located? My script is the child of the part that kills you when you touch it and it works fine. I don’t know what is going wrong when you do it.

If nothing works, then just make the kill zone smaller so it doesn’t touch any other part but it’s barely noticable, or you can rename the part that it will touch to something like “Ignore” or add a value set to true and then check if the part that the kill zone is touching isn’t the parts that are named “Ignore”

My script is located in a model, with a KILLZONE instance, and a script. KILLZONE, in this context, is a variable that contains the KILLZONE instance. Every few seconds, I want the KILLZONE part to kill all players touching it.

If you just want to kill the players touching KILLZONE then you can just check if a part’s parent has a humanoid and then set the humanoid’s health to 0, or just set the humanoid’s health to 0 no matter if it doesn’t exist, it will make a few errors tho

just do something like this instead then (this doesn’t filter out the script though)

	plr.Parent:FindFirstChild("Humanoid").Health = 0

Have you tried workspace:GetPartsInPart()? I’m pretty sure .Touched events don’t work for parts with .CanCollide off.

.Touched does work with parts that are .CanCollide = false

I thought I saw something about it not being reliable with non-CanCollide parts. Sorry.

However, Touched fires a ton of times.

I understand, sometimes you just don’t use .Touched

check in the properties of a part in the cantouched section and set it to true also simply use the if condition asking for the player’s life and so it will not shoot every so often or you could put a wait on it

Try adding TouchInterest to the part. To do this, hook up a function to the part’s Touched event. You don’t even have to actually put anything in the function; this alone will give the part a TouchInterest object, and that may allow other things to work as well. It happened to me once.

Edit: I suspect network ownership is an issue here. Try setting the part’s network ownership to nil, unless it’s already anchored and moves via other means. Alternatively, you may need to create a copy of the killzone for each player in the game and set each copy’s network owner to its respective player.

or how about you use a local script which asks if the piece is touched and if the player is still alive and then if he touches it then kill him

I’ve got a creeping suspicion that your issue is related to CollisionGroups.

If the characters body parts are not within the same collision group as your KILLZONE, your code is working, but is simply not detecting the player because it exists elsewhere in a different collision group.

I got this deduction by this part you mentioned here:

Maybe try double checking CollisionGroups on the character? If you can’t do that, try setting the KILLZONE the same CollisionGroup as the Characters HumanoidRootPart, that way you can get the Humanoid and kill the Player. I’m not entirely sure if this is the case, but someone more experienced with the use of CollisionGroups may be able to help you here.

1 Like

I don’t have any extra CollisionGroups (yet)