How to make a melee SWep?

This is one of my bigger challenges, I have Never figured out how to make a Melee weapon. I’ve heard all you need to do is modify the Primary Fire option, but I don’t know what to do, And I would very much appreciate it if anyone can help me out. Thanks in advance!
Here is my SWep code, if you need to see it:

Perform a trace with

util.TraceLine or

util.TraceHull and damage the hit entity (if it’s valid!) with

Entity:TakeDamage or


I, don’t understand. Do I do those in the Primary Fire function? Or no?

Yes in the PrimaryAttack function - that’s where the logic for your primary attack goes.

Make sure you use

Player:LagCompensation on the owner as well.

Alrighty, Thanks so much guys!