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

GetRankInGroup script doesn't makes the gui disappear?

Greetings, thank you for checking my post out! I was wondering why this script wasn't working. I would be glad if you could help me!

game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(2) >= 10 then
        game.StarterGui.GUI.Enabled = true
    else
        game.StarterGui.GUIy.Enabled = false
    end
end)

4 answers

You are changing the StarterGui instead of the PlayerGui. The StarterGui is a container that stores all gui that will be given when a player joins. The PlayerGui is the gui the player sees.

Here's a fixed version:

game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(2) >= 10 then
        player.PlayerGui.GUI.Enabled = true
    else
        player.PlayerGui.GUI.Enabled = false
    end
end)

5 comments

0

Thank you for trying to help, sadly I can still see the gui for some reason. What is causing this issue?

0

Did you want the player to see the gui if their rank is under 10 or greater than 10?

0

Is visible true and is the position of the frame actually on the screen?

0

Greater, but I checked, the ranks were correct.

0

I want them to see it, if their rank is greater than 10. Visible is true and it is on the screen. As I said, the problem is that I still can see it. Thank you for the help, anyways!

Hello there!


The problem with your code is that StarterGui is the container of all the gui that will get cloned to the player's PlayerGui. Instead of using StarterGui, use the player's PlayerGui as it's the actual gui of the player.


Also, make sure ResetOnSpawn is false otherwise the gui won't get enabled when you respawn.


Here's the fixed script.

game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(2) >= 10 then
        player:WaitForChild("PlayerGui").GUI.Enabled = true
    else
       player:WaitForChild("PlayerGui").GUIy.Enabled = false
    end
end)

Hope this helps! Cheers!

3 comments

0

Greetings! Sadly, I can still see the gui, any ideas what is causing the issue?

0

Did you want the player to see the gui if their rank is under 10 or greater than 10?

0

I want them to see it, if their rank is greater than 10. Visible is true and it is on the screen. As I said, the problem is that I still can see it. I hope you can help!

I really don't know if this will work but try it I guess

game.Players.PlayerAdded:Connect(function(Player)
Player.GroupId = 0000000 -- Put ur group id here    -- New line
if Player:GetRankInGroup(2) >= 10 then
        game.StarterGui.GUI.Enabled = true
    else
        game.StarterGui.GUI.Enabled = false
    end
end)

You need to change it on PlayerGui instead, and it needs to wait for the GUI to be moved from StarterGui to PlayerGui before disabling it.

Try like this:

game.Players.PlayerAdded:Connect(function(Player)
	local GUI = Player.PlayerGui:WaitForChild("GUI")
    if Player:GetRankInGroup(2) >= 10 then
        GUI.Enabled = true
    else
        GUI.Enabled = false
    end
end)

As mentioned by youtubeMasterWOW, you will need to make sure that ResetOnSpawn is false on the GUI or it will get enabled again when they respawn.

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