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)
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)
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!
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.