There are a few different ways that you can film gameplay on TikTok. The most popular method is to use your phone's screen recording feature. This can be done by opening the game you want to record and then pulling down the notification shade from the top of the screen. There should be a button there for Screen Record; tap it and then hit Start Recording. The game will then be recorded until you stop it, and you can edit and post the footage however you like.
Another way to record gameplay is by using an external camera, if your phone supports it. This can give you better quality footage than using your phone's screen recorder, but it's more complicated to set up. You'll need to connect your camera to your phone somehow - usually via USB - and then launch the game you want to record. Again, you can edit and post the footage as you see fit once it's been recorded.
Finally, if you're playing on a console or PC, there are various capture devices available that will let you record your gameplay footage directly from there. These tend to produce the best quality video, but they're also generally more expensive than just using your phone (unless you already have one lying around). If this is something you're interested in pursuing, just do a quick search online for game capture device and see what options are available for whatever platform you're playing on.