How do i make killbricks?

[Brick] Jazc11
Joined 14/02/2021
Posts 68
10:34 PM 28/03/2021
I want to do a script that makes every brick named "killbrick" kill u!


[Code] Noah Cool Boy
Joined 20/06/2019
Posts 1,129
11:37 PM 28/03/2021
Easy stuff!
First, get all the bricks named "killbrick"

let killbricks = world.bricks.filter(brick => brick.name == "killbrick")

Then, we just need to listen for every time a player touches one of those bricks using brick.touching
(See documentation, https://brickhill.gitlab.io/open-source/node-hill/classes/brick.html#touching)

We want to kill the player which touches the brick, so this is what we do
killbricks.forEach(killbrick => { // For every killbrick
killbrick.touching(plr => { // When a player touches the brick
plr.kill() // Kill that player
})
})


[Brick] Jazc11
Joined 14/02/2021
Posts 68
02:32 AM 29/03/2021
Quote from Noah Cool Boy , 11:37 PM 28/03/2021
Easy stuff!
First, get all the bricks named "killbrick"

let killbricks = world.bricks.filter(brick => brick.name == "killbrick")

Then, we just need to listen for every time a player touches one of those bricks using brick.touching
(See documentation, https://brickhill.gitlab.io/open-source/node-hill/classes/brick.html#touching)

We want to kill the player which touches the brick, so this is what we do
killbricks.forEach(killbrick => { // For every killbrick
killbrick.touching(plr => { // When a player touches the brick
plr.kill() // Kill that player
})
})
Thanks so much!


[Tea] pompeii
Joined 19/06/2019
Posts 9,155
03:46 PM 31/03/2021
Quote from Jazc11 , 02:32 AM 29/03/2021
Quote from Noah Cool Boy , 11:37 PM 28/03/2021
Easy stuff!
First, get all the bricks named "killbrick"

let killbricks = world.bricks.filter(brick => brick.name == "killbrick")

Then, we just need to listen for every time a player touches one of those bricks using brick.touching
(See documentation, https://brickhill.gitlab.io/open-source/node-hill/classes/brick.html#touching)

We want to kill the player which touches the brick, so this is what we do
killbricks.forEach(killbrick => { // For every killbrick
killbrick.touching(plr => { // When a player touches the brick
plr.kill() // Kill that player
})
})

Thanks so much!
you can use this with other obstacles like moving parts and such so knowing how to specifically pick bricks named one thing is useful, so if you learn a few basic other functions you can easily change it around to make some other obstacles, you should try

1