You don't necessarily have to build one from scratch — Roblox's free models library contains plenty of ready-made hat givers you can drop straight into a place.
A hat giver is fundamentally a part that detects when a player touches it and then adds a hat to that player's character. In Roblox Studio that means a script using a touch event, a check that the touching object belongs to a player, and a call to give the hat.
Searching the free models for "hat giver" is faster for a first attempt. Reading through one of those scripts is also the quickest way to learn the pattern before writing your own.