So I have stumbled into a problem that I cannot seem to overcome.
I need to make something happen in the PlayerGui of a player who clicks on a TextButton. I thought simply doing something like this whould suffice:
TextButton.MouseButton1Click:connect(function(player) --stuff happens here local scroll = player.PlayerGui.Chat --I have a GUI named 'Chat' in their PlayerGui that I created earlier.
But since this all happens inside another function, it can't reference "player" as the one who clicked for some reason. So could someone help me figure out how to reference the Player who clicks on a TextButton?
EDIT:Sorry, I forgot to clarify. This is running inside a normal script inside a model, not in a local script.
All GUIs are locally run. This means that the code to display the GUI is executed on the players computer and that GUIs must be put in local scripts. Because of this, you should reference the player owner of the script instead.
Ok, here's a simple solution. I think DewnOracle already kind of answered this, but I'm not sure if you understood. Make sure that the following code is inside a LocalScript, that's in the TextButton.
TextButton.MouseButton1Click:connect(function() player=game.Players.LocalPlayer --This gets the player that the gui is inside of, and sets the variable to him/her. local scroll = player.PlayerGui.Chat