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

How do I make a GUI only a certain rank can see in my group?

Asked by 5 years ago

I can't figure this out. Roblox is saying Player is unknown, and required rank is unknown...

requiredRank = "250"

local groupId = 4274644

if player:IsInGroup(groupId) and player:GetRoleInGroup(groupId) >= requiredRank then
   game.StarterGui.Rooms.Enabled = true
   game.StarterGui.StaffTeleport.Enabled = true

end

I want to make it so Moderators and up can see the GUI when joining the game, but members below don't see it.

Thank you for helping :P

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

StarterGui and PlayerGui

The problem with your script is that you are trying to edit a player's gui from StarterGui. This service is basically where PlayerGui clones out of when the player first joins and when they respawn. In other words, for the changes to show, you'll have to reset their character. But we want to make the changes happen without resetting, no? To prevent that, we can use the PlayerGui, if we edit any GUIs in there, they will show instantly, and any LocalScripts placed in there will start to run.

local requiredRank = 250 
-- it's a number, not a string. and use local variables! global variables are bad practice

local groupId = 4274644
local client = game.Players.LocalPlayer

if client:GetRoleInGroup(groupId) >= requiredRank then
   client.PlayerGui.Rooms.Enabled = true
   client.PlayerGui.StaffTeleport.Enabled = true
end

0
The PlayerGui is finding it, when I test my game, but the gui itself is not getting enabled oddjjctiger1 9 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Your script is find... But you are Accessing StarterGui this is basically enabling The Gui's you want staff members too have. To be enabled. in the StarterGui

Instead of using this

game.StarterGui.Rooms.Enabled = true game.StarterGui.StaffTeleport.Enabled = true

use this.

player.PlayerGui.Rooms.Enabled = true player.PlayerGui.StaffTeleportEnabled = true

****ALSO: How are you accessing player. You should be using a PlayerAdded Function if you are accessing player (In a normal script.)****

Answer this question