How to make kill zone?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Add kill zone: Example: A function is fired and if the player is in an area he dies.

  2. What is the issue? Include screenshots / videos if possible!
    I do not know how to achieve it.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried making a brick, that if touched the player dies, but if a player doesn’t move he will not die so it doesn’t work.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

I just want to want to know what to use, I don’t need the entire script I guess. Thank you!

Have you set the Touched parameter correctly? Your concept should work, but it all depends on how your set it up :thinking:

You can use FindPartsInRegion3 and loop it every increment to look at the parts in the kill zone, and if they’re part of a humanoid, set the humanoid’s health to 0

@Reksioq3_2 FindPartsInRegion3 sounds perfect for that use, you can use the formula the article mentions for finding the region minimum and maximum size, get the parts in it, if they’re a limb of a character, get the humanoid and set the health to 0

3 Likes

The thing is, when the bomb explodes and I use the touched function, if player doesn’t move it won’t kill him :frowning:

1 Like

I never used it, but I’ll try :wink:

1 Like

Please tell me if you have any issues with anything so I could help!

Alrighty, works well! Thank you :grinning_face_with_smiling_eyes:
Worried it will lag with a lot of parts, but it shouldn’t, right?

2 Likes

I don’t believe it should lag, even if it would lag, it would take tons and tons of parts to finally so slight lag.

If you have anymore issues don’t be afraid to make another post!

2 Likes

Update: If there is too many parts, it doesn’t work :frowning: here is the script:

local region = Region3.new(part.Position - part.Size/2, part.Position + part.Size/2)

while true do
	local parts = workspace:FindPartsInRegion3(region)
	for i, part in pairs(parts) do
		local plr = game.Players:GetPlayerFromCharacter(part.Parent)
		if plr then
			print(plr.Name)
		end
	end
	wait(0.01)
end

Change

local parts = workspace:FindPartsInRegion3(region)

To

local parts = workspace:FindPartsInRegion3(region,nil,math.huge)

The default number of parts it finds is 20, math.huge will make it so it detects any number of part. Or optionally you can just set a number that you’ll never reach, such as 100000

1 Like

Now it works, thanks! And it doesn’t lag too, thank you very much!

1 Like

Anytime! If you have anymore issues don’t be afraid to make another post!