This is a simple method of detecting the costume of the object touching the player sprite. Move the player sprite with the arrow keys. Look inside to see how it works.
This is not the only method for doing this, nor is it necessarily the best. But it is relatively simple. I just realized that I made a project with an even simpler method last year, based on a project by @colinmacc: https://scratch.mit.edu/projects/664534477/