What is the fastest way to make a kill brick

So a friend is wondering what will perform the fastest make a brick kill a character. We think the collection service but there is a lot of ways to do things so is there something else?

3 Likes

Using CollectionService probably would be the best approach for the job. It’s about as easy and intuitive as it gets.

local killbrickConnections = {} --Keep a table of connections to disconnect later!!

local function onTouch(hit)
   --Do What Every other script does
end

for _,killbrick in pairs(game:GetService("CollectionService"):GetTagged("Kill Brick")) do
   local connection = killbrick.Touched:Connect(onTouch)
   table.insert(killbrickConnections,connection)
end
2 Likes

To clearify, we know how to script it, our only question is about what would be the fastest with peformance.

I’m not sure the “performance” of a kill brick is something worth considering. Why do you think this?

1 Like

I mean like how you can prevent it from making the game lag.

A kill brick shouldn’t be making the game lag. The problem lies elsewhere most likely.

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        script.Parent.Touched:Connect(function()
            char.Humanoid.Health = (0)
        end)
    end)
end) 

That’s what I would do

1 Like

Please don’t, that will make a lot of RBXScriptConnection and possibly consume a ton of server memory. You are basically telling the server, “Hey make another event when a new player joins”.

To the @OP and his @friend. I suggest using CollectionService or keep all the KillBricks in a Folder.
Why? Getting every part in a variable is so tedious, and sometimes you can’t even understand your script anymore.

2 Likes

Oh, sorry I didn’t know that.

Thanks for letting me know :+1:

1 Like

not lag. read the question again.

Try using collection service which will allow to you to mantain all kill bricks with only 1 script.

Yeah what I was thinking. But this was for a friend and he was asking bc he was taking a new quiz and wanted to make sure that was the answer.

1 Like