Detecting name of a Player using a Script

How do I detect the name of a player when clicking on an ImageButton inside a Script and not in a LocalScript?

I know that by using a localscript, you can detect the name easily, but I wanted to detect it by a script inside an ImageButton, what do I do?


You can only detect a click of an ImageButton locally I’m pretty sure, so it’s the same way, there isn’t a way for you to get a click of a GUI element from the server.

1 Like

Sad, I needed this for a PC job.

What are you trying to achieve? Maybe I can provide you with another solution

I have a system where the person clicks on a thing called a “checker” that takes up the PC and prevents others from using it. By occupying it, the PC would become available and options would become available. There is this problem, one of the options is an imagebutton and I wanted to make a way that only the player could use it, then comes the script checking if the player has the same name as the stringvalue.

The problem from it, it isnt. Its located from a part of the Computer.

Put the surfacegui in startergui but set the “adornee” value to the computer screen. This will allow you to use local scripts, as you have a client-side surfacegui.

1 Like

It would fix, that would be sure. But it would work for multiple PC with same function?

1 Like

I think the best option in that case would be to use a local script (in starterplayer) to clone the surface gui for each PC.

1 Like

I can try it, its seems the best response that I got

1 Like

Forgot that I have another thing that benefits this, I have other thing that makes sure the PC is locked to the only one player. As the Gui doesnt exist (yet), it wouldnt be able to interact to the gui himself (So the options of it, be availaby for the only one player)

1 Like

You can’t run a serverscript there, it doesn’t work like that

You can use remote events for this, use both a local and server script, learn more about remotes from here, Bindable Events and Functions | Roblox Creator Documentation

Please don’t put scripts inside objects that are only supposed to be available locally. You can do it, but it’s such a bad practice.

1 Like

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