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

instant kill brick script(help, script provided) ??

Asked by
CHATED 10
9 years ago

i tried this script:

script.Parent.Touched:connect(function(_o)
pcall(function()
_o.Parent:BreakJoints()
end)
end)

but sometimes if the character constantly jumps on the brick this script it inserted into, the BreakJoints doesn't work(sometimes the lava glitches)

how do i make it so that the BreakJoints() happens immediately, or almost immediately

e.e

3 answers

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

This is a very odd way to make a kill brick. It is normally done as following:

function kill(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.Health = 0
    end
end

script.Parent.Touched:connect(kill)

--Or, with an anonymous function,

script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        hit.Parent.Humanoid.Health = 0
    end
end)

However, there is no way to prevent occasional glitching. If the touched event does not fire, it is Roblox's problem and there's nothing you can do about it. Sometimes it helps to make the brick CanCollide false, but even still it sometimes does not fire the touched event.

Ad
Log in to vote
0
Answered by 9 years ago

Here is how I would do it..

script.Parent.Touched:connect(function(Hit)
    if game.Players:GetPlayerFromCharacter(Hit.Parent) then
        Hit.Parent:BreakJoints() -- For Players
    elseif Hit.Parent:FindFirstChild('Humanoid') then
        Hit.Parent.Humanoid.Health = 0 -- For NPCs
    end
end)
  • I hope this helps.
Log in to vote
-1
Answered by
lomo0987 250 Moderation Voter
9 years ago
function kill(plr)
    if plr.Parent.Humanoid then
        plr.Parent.Humanoid.Health = 0
    else
        print("No Humanoid")
    end
end

script.Parent.Touched:connect)kill)
0
Thanks CHATED 10 — 9y

Answer this question