Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

KillBrick doesn't work if you stay jumping?

Asked by 4 years ago

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)
0
Try printing obj, does it detect the hit? iOwn_You 543 — 4y
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) mikey2019d 43 — 4y
0
Sorry for the late reply, but the solution was changing my game to R6! SobbingSabah 6 — 4y

2 answers

Log in to vote
1
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

Answer this question