RB-004
Roblox kill brick script
A part that hurts or kills any character that touches it.
- Script type
- Script
- Where it goes
- Inside the Part
- Category
- Hazards and pads
For your own game in Roblox Studio. Not for use in other people's games.
The code
-- Kill brick: put this Script inside the part that should hurt players.
local DAMAGE = 100 -- 100 kills a normal player (max health is 100)
local COOLDOWN = 1 -- seconds before the same character can be hurt again
local part = script.Parent
local recentlyHit = {} -- humanoids that were just hurt
part.Touched:Connect(function(hit)
local humanoid = hit.Parent and hit.Parent:FindFirstChildOfClass("Humanoid")
if not humanoid or humanoid.Health <= 0 then
return
end
if recentlyHit[humanoid] then
return
end
recentlyHit[humanoid] = true
humanoid:TakeDamage(DAMAGE)
task.wait(COOLDOWN)
recentlyHit[humanoid] = nil
end)How to set it up
- In Studio, insert a Part (Model tab, Part). Make it red if you like.
- In the Explorer window, hover over the Part, click the plus button, and add a Script.
- Delete the default print line and paste the code.
- Press Play and walk onto the part.
Change it
- Change DAMAGE to a smaller number, like 20, for a part that hurts but does not kill.
- TakeDamage does nothing if the player has a ForceField. That is normal. Spawn protection uses one.
- If nothing happens, check the Script is a child of the part and not of the Workspace.
- It also hurts NPCs with a Humanoid. That is usually what you want.
More in Hazards and pads
More Roblox tools
- Shirt and pants templatesFree Roblox clothing templates to download: hoodies, jerseys, jeans, joggers and more.
- Robux tax calculatorWork out what you receive after the marketplace fee, or what to charge.
- Robux to USD calculatorConvert earned Robux to dollars at a DevEx rate you can edit.
- Shirt and pants template makerColour each panel of the 585×559 clothing template and download it.
- Username generatorGenerate usernames that fit the 3–20 character rule.