Creating A Custom Character
Creating A Custom Character
|Prerequisites||Have a project with an arena set up from the Arcade Action - Intro lesson|
|Lesson Time||10-15 minutes|
Roblox provides a default human character for all games, but you can use any model you want for player characters. For this game, the player will pilot a ship made out of basic parts.
Creating Player Ships
All characters require a HumanoidRootPart to function as a character. The HumanoidRootPart is used to move characters around the world. The model for the ship will be made out of two parts. The main body of the ship will be the HumanoidRootPart. The second part will be made out of a sphere for the ship’s blaster.
Making Different Ships
If you chose to make the ship out of parts other than just one part, you might need to modify the given code to make everything work.
- Under Workspace, add a Model.
Models are used to group multiple parts or objects into a single object.
- Rename the model StarterCharacter. Make sure the capitalization is the same, since it will be used in the code.
- Inside of the StarterCharacter model, add a Part renamed HumanoidRootPart, and a Part renamed Blaster. Make sure to capitalize the parts the same as the image below.
Set the Primary Part
For the model to be able to move, the primary part for the model for the model needs to be set. In this case, the primary part will be HumanoidRootPart.
- Select the StarterCharacter Model.
- In the Properties window, set the
PrimaryPartby clicking on PrimaryPart and then select HumanoidRootPart.
Put the Ship Together
The ship and blaster need to be placed at the center of the arena, and then scaled up a little. If the model is not placed at the center of the arena, it won’t work spawn properly. Instead of dragging the ship around, move the ship to precisely the right place by using the Properties window.
- Select HumanoidRootPart.
- In the Properties window, next to Position, type
1,4,0to center it in the arena. Make sure to use commas to separate the values.
- To make the ship larger, change the size to about
8,8,8. It’s okay if your ship size is slightly different.
- Before positioning the Blaster, make sure Collisions are turned off.
- Position the Blaster at
1,4,-4and set size to
- Change the BrickColor or Material of HumanoidRootPart and Blaster to what you want the ship will look like.
- Now that the ship is made, playtest to see what happens.
That doesn’t look good. Looks like the parts aren’t connected to each other.
Weld The Blaster to the Ship
To fix the problem at hand, glue the parts together using a WeldConstraint between the blaster and HumanoidRootPart.
- Stop the playtest.
- In the Explorer, under Workspace, add a WeldConstraint.
- Drag the WeldConstraint object to the Blaster in the StarterCharacter model.
- Under WeldConstraint, in the Properties window, set the
- Set the WeldConstraint’s
- Playtest again and make sure the parts are welded together.
Spawning Custom StarterCharacters
Models for player characters need to be moved under StarterPlayer. If the model isn’t moved, the player’s Roblox avatar will spawn instead.
Move into StarterPlayer
- Move the StarterCharacter model to StarterPlayer to overwrite the default player model. Once moved, the ship should disappear from the game window.
- Playtest the game to see the new custom character. The ship will fall from the sky.
Overwrite Default Scripts
Roblox will add certain default scripts for every player that joins the game. This saves time when developing a standard Roblox game, but causes problems with custom games like this one. For this game, replace the health, sound, and animation scripts.
- In the Explorer > StarterPlayer > StarterCharacterScripts add three Scripts. Rename them:
Troubleshooting the Custom Character
Check the following if your ship isn’t spawning when you click Play Now.
The ship Model:
- Is named StarterCharacter.
- Has two parts named HumanoidRootPart and Blaster.
- Has HumanoidRootPart set as the primary part.
- Is centered in the middle of the arena.
- Has been moved to ServerStorage.
These documents are licensed by Roblox Corporation under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Roblox, Powering Imagination, and Robux are trademarks of Roblox Corporation, registered in the United States and other countries.