Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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.

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.
function kill(plr)
	if plr.Parent.Humanoid then
		plr.Parent.Humanoid.Health = 0
	else
		print("No Humanoid")
	end
end

script.Parent.Touched:connect)kill)

1 comment

0

Thanks

This discussion is preserved as it was. New answers, comments, and votes are closed.