Getting a player's group rank from a SurfaceGui

So, i’ve been trying to get what’s basically a wall terminal to grab a player’s group rank so that it can determine if it displays the information or makes a access denied screen pop up. However, i’ve only gotten it working with a tablet tool.

1 Like

Hey, is it like a TextButton on a SurfaceGui that a player clicks, similarly to how they would presumably be clicking a button on the tablet tool?

Yeah it’s like a login screen that checks your rank and opens to like several commands.

In that case you would go about getting the group ID, and then getting players group Role.

local groupID = youridhere

script.Parent.Activated:Connect(function(plr)
 plr:GetRoleInGroup(groupID) == ROLENUM or >= ROLENUM then  --if this doesn't work try GetRankInGroup()
      -- The Remaining commands if is in that rank,
else
-- The remaining for those without the rank
  end
end)

By commands, I mean like buttons where if you click them it plays an alarm or something.
Unless that’s what you meant to do in that script.

However, I’ll try it and see what happens.

Something about a syntax error at

== ROLENUM or >= ROLENUM then

You could use the Player:GetRankInGroup (roblox.com) method to check if they have the required rank to access the display.

local function IsRequiredRank(Player, RequiredRank)
    return Player:IsInGroup(GroupId) and Player:GetRankInGroup(GroupId) >= RequiredRank -- Is the player in the group? And is their rank higher or equal to the required?
end

...

if IsRequiredRank(Player, 254) then -- Do they have a rank of 254 or higher in the group? If so...
    print("Welcome", Player.Name)
else -- Otherwise...
    print("Access denied for", Player.Name)
end

EDIT

I don’t quite understand – GetRankInGroup works both on the server and the client, only it doesn’t cache the result when called on the client. A SurfaceGui (as others have pointed out) can only be seen when in a player’s PlayerGui (the Adornee property can be set to the part however).

The information could be verified/handled on the server, which would be then showed on the client if that’s a solution.

1 Like

Let me be more specific.

See, it’s going to be a login screen on some wall, and I’m gonna be doing this with a ServerScript, not a LocalScript because it doesn’t work because I assume it’s not a ScreenGui, it’s a SurfaceGui.

So yeah. (Might be confusing, I’m not the best at english.)

Quoted from the Roblox Developer Reference (SurfaceGui):

Note: SurfaceGuis must be descendants of PlayerGui in order to know the player who is interacting with it.

I haven’t personally used SurfaceGui but if it is how I think
Player.PlayerGui.SurfaceGui, then you can use that path to get the player.

Otherwise, you could try using theGetDescendants function paired with IsA
(I’ve never tried it before)

ScreenGuis and SurfaceGuis are still guis. Doesn’t matter which you put a TextButton in, you will require a LocalScript to record inputs with them, unless you have another workaround for it. In general, you should be using LocalScripts for any amount of work using guis.