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

SurfaceGui Only accessible to a specific group rank and above?

I am struggling with a issue at the moment. I have a GUI on a part and I am trying to make it so only the frame that allows you to control it is visible to people above a certain rank. It is supposed to change from the "Disabled" gui to "ShutterController" gui but it isn't working. May somebody be able to help me solve this issue I am having. The code is below. Just so you know the lowestViewRank will be set higher and I am in the group and above that rank number but the GUI is not changing.

local groupId = 5002973
local groupService = game:GetService("GroupService")
local lowestViewRank = 1
local HighestViewRank = 255

if game.Players.LocalPlayer:GetRankInGroup(lowestViewRank) < HighestViewRank then
	script.Parent:FindFirstChild("Disabled").Visible = false
	script.Parent:FindFirstChild("ShutterController").Visible = true
end

4 comments

0

Just to let you know the LOCAL SCRIPT is the the surface GUI of the part.

0

is it in serverscriptservice?

0

I have put it in there now and re linked the script.Parents but it still doesn't to have appeared to of worked.

0

The reason for the error maybe that you didnt reference the player who joined the game.

3 answers

lowestViewRank isn't the group you are checking, it's the rank.

The

GetRankInGroup()

Function requires the group id as the parameter, NOT the lowest rank. It returns that player's rank in that specific group.

So, you would do:

if game.Players.LocalPlayer:GetRankInGroup(groupId) >= lowestViewRank and game.Players.LocalPlayer:GetRankInGroup(groupId) <= HighestViewRank then
	
	script.Parent:WaitForChild("Disabled").Visible = false
	script.Parent:WaitForChild("ShutterController").Visible = true
	
 end

9 comments

0

Does this still need to be in serverscriptservice?

0

No. This must be in a LocalScript, and LocalScript's only run in thing like PlayerGui. Move it to a LocalScript and put it in PlayerGui and it should work.

0

Because you can't get "LocalPlayer" in a server-sided script.

0

It has not seemed to have worked, I have written the code below to show you and see if it is written correctly

0

What are the errors?

0

I edited my answer, try doing WaitForChild instead of FindFirstChild

0

No errors were outputed, but the GUI isnt changing from the disabled gui to shuttercontroller gui.

0

Just a question. For it to take it effects does it need to be published to roblox then ran in the roblox game or will studio work just as fine? Also the waitforchild does not of seemed to have worked either.

0

Try publishing it.

It has not seemed to have of worked the code is below so you can see if I wrote it correct, the Local Script is in the surfacegui and I dont know what is causing it to stop it from changing.

local groupId = 5002973
local groupService = game:GetService("GroupService")
local lowestViewRank = 1
local HighestViewRank = 255

if game.Players.LocalPlayer:GetRankInGroup(groupId) >= lowestViewRank and game.Players.LocalPlayer:GetRankInGroup(groupId) <= HighestViewRank then

    script.Parent:FindFirstChild("Disabled").Visible = false
    script.Parent:FindFirstChild("ShutterController").Visible = true

 end

4 comments

0

By the way, what is Disabled? A frame? Or surfaceGui? Same for shuttercontroller

0

They are both frames. I am trying to disable the visibility of the Disable and enable the visibility on the Shutter controller.

0

Both Frames are in a surfacegui which is where the script is located.

0

You dont need to get the localplayer

Try this script: Also make sure this is in a local script inserted in startergui If that doesn't work use a remote event

game.Players.PlayerAdded:Connect(function(Player)
    if Player:GetRankInGroup(5002973) >= 1 and  Player:GetRankInGroup  <= 255 then
script.Parent:FindFirstChild("Disabled").Visible = false
    script.Parent:FindFirstChild("ShutterController").Visible = true
        print("Player is the owner of the group, 'LOL'!")


    else
        print("Player is NOT the owner of the group, 'LOL'!")
    end
end)

1 comment

0

This does not to have worked either, I do not know how remote events really work but if it fixes it may you be able to take me through how to do it?

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