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

GetRankInGroup script doesn't makes the gui disappear?

Asked by 4 years ago

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

Log in to vote
1
Answered by
Raccoonyz 1092 Donator Moderation Voter
4 years ago
Edited 4 years ago

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)

0
Thank you for trying to help, sadly I can still see the gui for some reason. What is causing this issue? ggAmazingMan 32 — 4y
0
Did you want the player to see the gui if their rank is under 10 or greater than 10? youtubemasterWOW 2741 — 4y
0
Is visible true and is the position of the frame actually on the screen? kingblaze_1000 359 — 4y
0
Greater, but I checked, the ranks were correct. ggAmazingMan 32 — 4y
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! ggAmazingMan 32 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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!

0
Greetings! Sadly, I can still see the gui, any ideas what is causing the issue? ggAmazingMan 32 — 4y
0
Did you want the player to see the gui if their rank is under 10 or greater than 10? youtubemasterWOW 2741 — 4y
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! ggAmazingMan 32 — 4y
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

Answer this question