Assuming you're using a tilemap.
The first step is to pick a random point to check if it is valid or not. You'll need to save this point to a instance variables, since if it is valid after checking we'll want to move to that spot.
First set variables targetx and targety to round(random(layout.width)) and round(random(layout.height)).
Use system compare two values to check if tile at that location is valid. tilemap.tileat(positiontotilex(self.targetx)),positiontotiley(self.targety)) = valid tile.
If it is, then set pathfinding move to targetx and targety. Else run the event/function again with a new random target.