Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

SurfaceGUI TextButton for group members only?

Asked by
PredNova 130
9 years ago

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)


1 answer

Log in to vote
0
Answered by 9 years ago

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!

0
I just tested this, and all this seems to do is crash the game? :x PredNova 130 — 9y
0
I tested it in game and in studio, didn't have an issue. Verbero 0 — 9y
Ad

Answer this question