Best way to make kill bricks

I want to make a kill brick system where you step on the part and it kills you. But I don’t know what the best way to do this would be and I’m not a very good scripter.

I was thinking to put a script in ServerScriptService and put a BoolValue in every kill brick to tell the script if the part kills you

is there a better way to do this?

can someone help me fix my code as well? this is all i have right now this would not work.

Part.Touched:Connect(function(h)
if h.Parent:FindFirstChild("Humanoid") then
local plr = game:GetService("Players"):GetPlayerFromCharacter(h.Parent)
h.Parent.Humanoid.Health = nil

I would use collection service for your kill bricks.

local CollectionService = game:GetService("CollectionService")
local TaggedBricks = CollectionService:GetTagged("KillPart") --Add that tag in your kill bricks

local function Kill(part)
	part.Touched:Connect(function(hit)
		local Humanoid = hit.Parent:FindFirstChild("Humanoid")
		if Humanoid then --Makes sure that the humanoid exists
			Humanoid.Health -= 100 --Means the same as doing Humanoid.Health = Humanoid.Health - 100
		end
	end)
end)

for _, part in pairs(TaggedBricks) do
	Kill(part)
end

Basically, collection service just gets every single part with a certain tag. Just remember to add the “KillPart” tag to your kill parts.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.