Why do my traps take time to kill you? What could it be? Help

s 1-2 seconds to take effect. Long ago I used free models but I already deleted them, I also used plugins but I also deleted them and I don’t know what it could be. Any ideas? Please (I don’t know if I put it in the correct category, if you can correct me)**

Here the script that has the trap:

cript would not bring that delay in killing you.

Hello! This is posted in wrong section, try deleting the post and posting it in #help-and-feedback:scripting-support with more info provided (like the trap’s code), so we can help you.

I believe I’ve commented on another one of your posts but I just wanted to bring this up again; your issue may be because of an overload of scripts in the game or possibly a virus (this depends on the lag, I have not clue how serious it actually is). Make sure to stay away from free-models and check for random scripts being brought up when using plugins!

1 Like

There isn’t really anything in your script that delays the character’s death. Since a player’s character is network owned by the client, maybe try the same thing on a local script instead, like so:

local players = game:GetService("Players")

local touchPart = game:GetService("Workspace").Part --Change 'Part' to whatever your part is called.
local touchConnection

local function onTouched(hit)
    local plr = players:GetPlayerFromCharacter(hit.Parent)
    if plr then
        plr.Character.Humanoid.Health = 0

touchConnection = touchPart.Touched:Connect(onTouched)

Note: You should use :Connect with a capital C as opposed to :connect as it’s deprecated.

1 Like

Could be lag, or an issue with your game. Try pasting the same kill part in a new world/game/place and then see if it does the same. It might be your device, or it could be your script, which is extremely unlikely.

You shouldn’t have a script for every trap. Just use collection service and have 1 script manage all of your traps. Also that code looks old, you need to replace it.

Humanoids have a function called TakeDamage(), if you pass math.huge as the damage parameter then it will always kill the player instantly.

What would be an updated version of the script?

I did that a long time ago and the same thing happened, it took 1 second, I want it to die like Tower Of Hell, since that one dies instantly, literally.

I’m not going to spoon feed you, the devforum isn’t here for people to just give you scripts. Figure it out your self using what I told you, I’ve mentioned everything you’ll need to make a new script.

Well, I’ll try to find someone else, thank you anyway.fegs f

Not sure if that could be the problem but it might be because when you are full of accessoires, there is no humanoid in the parent of that accessory.
Try doing this:

   if hit.Parent:FindFirstChildWhichIsA("Humanoid") or hit.Parent.Parent:FindFirstChildWhichIsA("Humanoid") then
      local hitHumanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid") or hit.Parent.Parent:FindFirstChildWhichIsA("Humanoid") 

You could use h:TakeDamage() but i dont think it will change anything

Alright, first of all you got some deprecated stuff on your code:
connect which should be: Connect
findFirstChild which should be: FindFirstChild

Also if you have over 7000+ traps, holy the game could be overloading and lagging, which makes your touched event unefficient.

You said that you can’t delete/change the scripts because there are 7000 of them, but if you know where every single script is, such as knowing that every trap is called “Trap” in workspace, and each Trap has a part named “Main” with “Script” inside of it, you can run a command through the command bar in studio that looks something like this.

for _, trap in ipairs(workspace:GetChildren()) do
    if trap.Name == "Trap" then

And then your new trap script would be a single script that loops through every trap in workspace and handles the Touched in there rather than separate scripts for every trap

You could use a single script to manage all of them, check CollectionService, it can help out a lot, about the traps not working, it’s probably the game having too much server lag so it delays the touched event.

There’s nothing wrong with findFirstChild with a lowercase ‘f’, it’s just a matter of personal preference.

Excuse me, I’m new to all this, where do I put the code? For it to run

The script did not work, I do not delete anything

Try disabling CanCollide, kill bricks usually are slow to kill when it’s enabled.