Getting player who clicked a TextButton

I need help (again…) with a script.
So It’s been a while I’ve been trying to figure this out and so far google, youtube and devforum didn’t help me.
I need to get, with a server script, the player who clicked a button.
Please note the following:

  • I can’t use a local script.
  • The buttons aren’t on a fixed number and name. They are created by another server script and are different between each player.
  • The button is inside a Surface Gui.
  • .Activated doesn’t work.
  • The SurfaceGui (when the button may be clicked) is inside a tool in a character in the workspace.

I need it so it can prompt a purchase to the player. LocalScripts do NOT work (I already tried).
I hope I explained myself enough. Please let me know if you need more information.

1 Like

You simply can not, you have to use a LocalScript. What’s not working with prompting the purchase on the client?

1 Like

LocalScripts work, you are likely doing something wrong with your script placement.

It’s wrong that LocalScript doesn’t work in Workspace

It’s children of the textbutton (the localscript). I assure you it is not working. It loads while in backpack but doesn’t get the button click.

You could move the LocalScript outside of workspace, or change the RunContext to Client, though it’s weird to have scripts inside workspace.

You mean: “Its a child of the Textbutton”

That isnt true, LocalScripts do not work in the workspace, you need to modify a Server Script to run in that environment.

I can’t move the localscript outside of workspace. I need it to be inside the button which needs to be inside the workspace afterall

Sorry. I meant that localscript do not work in workspace. How do exactly change the running environment of a server script?

Do what @RickAstll3y said in his previous post:

Use a Regular Script, Change the Scripts RunContext peroperty to Client, which will make the Script run as a LocalScript, unlike a regular LocalScript, it will run in the workspace.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.