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

SurfaceGui Only accessible to a specific group rank and above?

Asked by 4 years ago

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
0
Just to let you know the LOCAL SCRIPT is the the surface GUI of the part. Eletrinn 4 — 4y
0
is it in serverscriptservice? MiniToonOOF 10 — 4y
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. Eletrinn 4 — 4y
0
The reason for the error maybe that you didnt reference the player who joined the game. JesseSong 3916 — 4y

3 answers

Log in to vote
0
Answered by
srimmbow 241 Moderation Voter
4 years ago
Edited 4 years ago

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
0
Does this still need to be in serverscriptservice? Eletrinn 4 — 4y
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. srimmbow 241 — 4y
0
Because you can't get "LocalPlayer" in a server-sided script. srimmbow 241 — 4y
0
It has not seemed to have worked, I have written the code below to show you and see if it is written correctly Eletrinn 4 — 4y
View all comments (5 more)
0
What are the errors? srimmbow 241 — 4y
0
I edited my answer, try doing WaitForChild instead of FindFirstChild srimmbow 241 — 4y
0
No errors were outputed, but the GUI isnt changing from the disabled gui to shuttercontroller gui. Eletrinn 4 — 4y
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. Eletrinn 4 — 4y
0
Try publishing it. JesseSong 3916 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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
0
By the way, what is Disabled? A frame? Or surfaceGui? Same for shuttercontroller srimmbow 241 — 4y
0
They are both frames. I am trying to disable the visibility of the Disable and enable the visibility on the Shutter controller. Eletrinn 4 — 4y
0
Both Frames are in a surfacegui which is where the script is located. Eletrinn 4 — 4y
0
You dont need to get the localplayer JesseSong 3916 — 4y
Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

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)
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? Eletrinn 4 — 4y

Answer this question