I just need to know how to get the last part of a string in gdscript: for example getting the numbers in this: @Terrain_0@21:<MeshInstance3D#34074526969>

You have some choices.

One way is to use substr() to extract the substring based on the character positions:
https://docs.godotengine.org/en/3.5/classes/class_string.html?#class-string-method-substr

You can also use the Regex class:
https://docs.godotengine.org/en/3.5/classes/class_regex.html?#regex
That's how I would do it, but if you're not familiar with regular expressions, it takes some effort to learn them. I can provide actual code for this if you want to see it.

Those links are for Godot 3.5. If you're using Godot 4, check its documentation in case there are changes in those areas.