I asked a similar question a few days ago, But now I'm trying to do the same with a SurfaceGUI, I've been using the exact same script but it doesn't work? (Only in Studio..)
There's no outputs and I've tried this in both a Local Script and Normal...
local groupid = 1196447 script.Parent.MouseButton1Down:connect(function(clicked) local plr = game.Players.LocalPlayer if plr:IsInGroup(groupid) then if plr:GetRankInGroup(groupid) >= 2 then script.Parent.Parent.Visible = false script.Parent.Parent.Parent.MainMenu.Visible = true else print("Player is not in group or does not have significant permissions") end end end)
ROBLOX does not detect clicked functions in surface GUIs if they are in a part. However, we can put the SurfaceGUI into the StarterGui and it will work. First, we must change some things in the script. The new code would be;
local groupid = 1196447 local plr = game.Players.LocalPlayer script.Parent.MouseButton1Down:connect(function(clicked) if plr:GetRankInGroup(groupid) >= 2 then --This will return 0 if the player isn't in the group, so the :IsInGroup() is not necessary. script.Parent.Parent.Visible = false script.Parent.Parent.Parent.MainMenu.Visible = true else print("Player is not in group or does not have significant permissions") end end)
Put the above code into a LocalScript in the textbutton. Next we need to move the GUI.
Step 1: Move the SurfaceGui (Only the GUI and it's children, not the part)
Step 2: In the command bar, type game.StarterGui.GUINAME.TEXTBUTTONNAME.Adornee = workspace.PARTNAME
Replace GUINAME with the name of the GUI, TEXTBUTTONNAME with the name of the buton, and PARTNAME with the name of the part. If the hierarchy of your game is set up differently than this example, just fix the command bar code accordingly.
More information here: http://wiki.roblox.com/index.php?title=Surfacegui
Hope this helps!