Tutorial:Working Hat Giver

Hello! This very quick tutorial will teach you how to make a working hat giver in Roblox Studio.

Before we begin, although this is an intermediate tutorial, you should have knowledge of everything from the Advanced Guide to Scripting.

Accessing the Hat
Firstly, you need to access the hat.

From Toolbox
If you use a free model from the Toolbox, it should already be placed in a model. One specific part has to be named "Handle," just like a Tool. Then put it into ServerStorage.

From Scratch
If you model a hat from scratch, one part needs to be named Handle. I will not get much into detail about modelling the hat. Again, place it into ServerStorage.

From the Avatar Shop
There are a lot of great hats in the Roblox Avatar Shop. If you wish to use one from there, copy the AssetId.

Then, in Roblox Studio, if you do not have a command bar at the bottom of your screen, insert it using a View Tab. Then, type the following into the command bar:

Replace XXXXXXXXXX with the AssetId. Now, there should be a model in ServerStorage. Best rename it to prevent any confusion.

Coding the Hat Giver
Now, insert a part into the Workspace. This will be your giver. You can model it as much as you want, but this is not a building tutorial. Insert a script into the Part.

First, we set up a Touched event:

Now, we need to check for the Humanoid, to see if the object that fired the event is human.

Finally, we clone the hat and parent it to the player's character.

So, when a player touches the part, the hat will be cloned and parented to the player's character.