How to check which player has pressed a UI button? (U5, PUN)

Hey there,

I’m looking for a way to check which player is pressing a UI button so that I can then reference that player.

I.E. There are 4 people in a game, one of them is using the shop and buys an item. How would I know which player is buying the item, and then reduce their money buy the cost?

I’ve been thinking on it for a while and I’m struggling quite a bit…

Anything that could help is appreciated, I’m quite sure that there is a way to do this. If any extra information is needed be sure to ask, I’ll supply :slight_smile:

There are lots of ways to do this that all depend on how you identify and define your players. For example, you could identify them by a profile name as @dr3th suggested and define them as an instance of a certain class. You could also send a single byte that identifies which player in the room pressed the button. Then it’s just a matter of communicating the identification and connect it to the corresponding player on all clients. Do you need specifics or is that good enough?