Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Get the name of the player who clicked a SurfaceGui Button?

I understand you can do this all well and good with a ClickDetector but I want to do it with a SurfaceGui Button. All it should is print the Clickers name: It's a ServerScript inside of the SurfaceGui.

--doctorbenny2011 09/04/2016 Started 11:00GMT

local a = script.Parent
local Part = a.Parent
local MainFrame = a.MainFrame
local Close = MainFrame.Closed
local Open = MainFrame.Open

--SoundsStart
local UG = Part.UserGranted
local UD = Part.UserDenied
local SU = Part.StartUp
local SD = Part.ShutDown
local DS = Part.DenyS
local AS = Part.AcceptS
local AG = Part.AccessGranted
local AD = Part.AccessGranted
--SoundsEnd

-- THIS BIT        \/\/\/\/\/\/
Close.Button.MouseButton1Down:connect(function(click)
	print(click.Name)
end)

2 comments

0

What objects are close and button?

0

Closed is a Frame, Button is a TextButton inside of Closed. @iUnEarthly

1 answer

Actually Client to SurfaceGui is possible, just not through a ServerScript. What you will need is a LocalScript, the Brick where you want the Gui to appear with a unique name, and the Gui placed in StarterGui.

Within the LocalScript you would have to use the Adornee property of SurfaceGui in order to set the part the Gui should be showing on.

script.Parent.Adornee = game.Workspace.PartWithUniqueName

From there, since it looks like you have the bulk of your script set up, you can use the LocalPlayer value of Players to receive your player value. You can then send a signal to the server via RemoteEvent if you need the server to do something for you.


######Hopefully this answered your question. If it did, do not forget to hit the accept answer button. Have any questions, feel free to post them in the comments below.

1 comment

0

But I'm going to have multiple screens. How would I pinpoint each one?

This discussion is preserved as it was. New answers, comments, and votes are closed.