How would you use GetRankInGroup to find a players rank using a SurfaceGui Button?
I would like it so that it is used within a "if" function that I am doing.
player = game.Players.PlayerAdded loading = false script.Parent.MouseButton1Down:connect(function() if loading == false then loading = true print("Login") script.Parent.Text = ("Logging In") wait(0.5) script.Parent.Text = ("Logging In.") wait(0.5) script.Parent.Text = ("Logging In..") wait(0.5) script.Parent.Text = ("Logging In...") wait(0.5) script.Parent.Text = ("Logging In") wait(0.5) script.Parent.Text = ("Logging In.") wait(0.5) script.Parent.Text = ("Logging In..") wait(0.5) if player:GetRankInGroup(731703).Value == true then script.Parent.Text = ("Access Accepted") wait(2) script.Parent.Text = ("Welcome!") wait(1) game.ServerStorage.TerminalData.Host.Value = true script.Parent.Text = ("Click To Login") loading = false else script.Parent.Text = ("Access Denied") wait(2) script.Parent.Text = ("Click To Login") loading = false end end end)
Is this was you needed?
I don't know where this script is running so you need to add in the player instance
e.g:-
script.parent.parent
to get the player rank:-
rank = "player instance":GetRankInGroup( --group id here)
The code below will check if a player that has entered the game has a rank equal to 255, in a group with an ID of 2. If they are, it will print "Player is the owner of the group, 'LOL'!", otherwise "Player is NOT the owner of the group, 'LOL'!" will be printed to the output.
game.Players.PlayerAdded:connect(function(Player) if Player:GetRankInGroup(2) == 255 then print("Player is the owner of the group, 'LOL'!") else print("Player is NOT the owner of the group, 'LOL'!") end end) Alternatively, you could use ternary operators to make the code shorter. game.Players.PlayerAdded:connect(function(Player) local Rank = Player:GetRankInGroup(2) print("Player is "..(Rank == 255 and "" or "NOT").." the owner of the group 'LOL'!") end)
Source here - http://wiki.roblox.com/index.php?title=API:Class/Player/GetRankInGroup