Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you make a Kill Brick?

Asked by 10 years ago

Kill Brick: A staple of an obby is the kill brick, a part that kills a player as soon as they touch it. These can be quite unforgiving depending on how they are laid out. This type of brick requires a very short script to work. Fortunately, this script is very versatile and is easy to add into our game.

On ROBLOX we have hosted a model of a part that contains the kill script, but to use it we first have to get it from the ROBLOX Catalog (don't worry, its free). Using models that other people have made is an important part of ROBLOX. Sometimes when your game will need an asset or script it can be convenient to use something someone else has already made. The model with the kill script can be found here. Make sure you are logged in and select "Take One".

Now return to Studio, click on the Insert tab, and then select My Models. This will open up a new window with all of the models you have either published or purchased. Click on the kill brick. This will insert it into the game. Place it 10 studs away from the beginning of the balance beam on the upper level of our obby. Insert another kill brick 4 studs away from the first one. Insert another 5 studs away. Repeat this, placing kill bricks along this platform with one extra stud spacing in between each until we have 6 kill bricks total.

Start up your game with the Play Solo button (you will have to go back to the Home tab). When our character touches one of the kill bricks our character model should get destroyed. What's nice about the kill script we are using is that the block can be any size or shape. If you decide to use this kill block in other games, you can scale or move the kill brick to any size you need and it will behave the same as in our obby. For now though lets leave the kill bricks as they are.

With the addition of kill bricks, our obby has started to become a little unforgiving to play. This may be desirable is some games, but lets add a checkpoint system to make our player's lives easier. Fortunately this is very simple to do with a special part called a Spawn Location.

Spawn Location: Until now we have been working exclusively with the basic Part. Most of the games will be made out of Parts, but ROBLOX has many types of objects that fill specialized roles. The Spawn Location is a Part that lets you control where your players will spawn, either when they join the game or after they die.

Lets start by adding a Spawn Location right after the first series of jumps. To add a Spawn Location to your game, right click in your workplace (make sure you are not right clicking a part or have a part selected). Hover over Insert Basic Object and select Spawn Location. This will insert a Spawn Location, which will look like a normal part. Resize it so that it is a 4 x 4 stud square, and place it on the 6th platform in our game. If we tested our game now we would find the player now appears on our Spawn Location. Lets take a moment to learn how Spawn Locations and Teams work.

In a ROBLOX game, a player can be part of a Team. Each team has a color associated with them. Spawn Locations will designate where players on a team will join the game by assigning that Spawn Location to a team. If more than one Spawn Location exists for a team, the player will spawn at a random one.

By default, players are not assigned to a team and will spawn at any spawn location that is designated as neutral. All Spawn Locations by default are neutral, so that is why our player spawned at our new location. To fix this, we need to make some changes to our Spawn Location.

Using the Select tool, click on the Spawn Location. Then, click on the View tab at the top of Studio and then select Properties. This opens a new window in Studio. This window contains a lot of detailed information about the selected Part. At the moment all we need to pay attention to are the options under Team. Check the option called AllowTeamChangeOnTouch and uncheck the option called Neutral. The first option means that if a player touches this Spawn Location, they will change to the team that the Spawn Location is associated with. The second option means the Spawn Location is not neutral, so it will not be used when a player is joining the game.

Try testing the game again with Play Solo. Notice that we now start at the beginning of the game. If we jump off the first platform, we will also respawn at the beginning of the game. Now move through the level and jump on the Spawn Location we just added. Nothing happens visually, but our character is now on the Team of the Spawn. If you jump off the level now, you will be respawned at the location. Using this system, we can create checkpoints throughout the level, so the player doesn't have to start over at the beginning if they die.

Lets add three new spawn locations to our game. We will make them all 4 x 4 studs. The first of these should be placed before our kill bricks, and the second after the kill bricks. The last Spawn Location will be placed on our last platform, right after the balance beam. Make sure that each of these Spawn Locations have Neutral turned off and AllowTeamChangeOnTouch turned on. Also change the TeamColor for each of these so that none are the same (this can be found in the Properties window directly under the Neutral option). Once you are done, test the level and make sure that these checkpoints work. After touching a Spawn Location, we should always return to that location after we die until we touch a new one.

Teleport: Now that we have kill bricks and checkpoints, lets add a teleport to our final platform so players can go through the game again without having to relaunch it. Like the kill brick this requires a script, but like the kill brick we have a model that takes all the scripting work out for us. You can get the teleporter here. Like the kill brick you can add it into your game by first clicking the Insert tab in studio, then My Models, and finally the picture of the teleporter. Once it is in the game, move it to the end platform.

This teleporter works by sending any player who touches it to a specific Spawn Location. Every part in ROBLOX has a name which can be used if a script needs to manipulate the part in some way. The default name of most parts is the same as the type of part they are (for example, parts all start with the name Part, Spawn Locations start with the name SpawnLocation). In this case our teleporter is going to teleport any player that touches it to a part called TeleportDestination. Lets add a new Spawn Location for this. Like the other Spawn Locations we will make it 4 x 4 studs. Move it to the origin of your game (the green arrow where the player initially spawns). Select this new Spawn Locator and open up the Properties window if it is not already open. Make sure to turn on AllowTeamChangeOnTouch, but in this case we can also leave the Neutral option on. Make sure that the TeamColor is different from the other Spawn Locations in the game. Scroll up in the properties until you see a field called Name. It should be called SpawnLocation at the moment. Click on the text and change it to read TeleportDestination (all one word, no spaces. Make sure the T and D are capital letters as well).

Our teleporter should work now. Start up your game with Play Solo and jump on top of the teleport block. Your character should return to the beginning of the level.

Next Steps: Now that we have added all of these neat features to our game, don't forget to publish your game and test it out online.

Sample Place: If you want to see what the game looks like when its finished visit the place here:http://www.roblox.com/WikiLesson2-place?id=155562628

Answer this question