Forgot how to Rank Lock a UI

Hey Devforum members, so! I have lost my mine and forgot how to rank lock a ui to make it visible for those ranks+ and not visible to those who are not the rank.

Assist if can please, thanks!

1 Like

Just use the :GetRankInGroup() method to get the user rank in the group (this is part of the player instance). Just then use an if statement to check if the user is a correct rank or not. You could make the UI non-viable to hide the UI or just use :Destroy() on it.

image

Main Script

local ServerScriptService = game:GetService(“ServerScriptService”)

local Service = require(ServerScriptService.StaffPanelSettings)

script.Parent.MouseButton1Click:Connect(function()

local Screen = script.Parent.Parent.Parent.Screen
Screen.Visible = false

local Screen = script.Parent.Parent.Parent.StaffPanel
Screen.Visible = true

end)

Settings Script

local Settings = {}

–Ranking Control

Settings.RankLockEnabled = true – Set to “True” if you want the Minimum Rank Lock to be enabled.
Settings.GroupId = 3287731 --Set to group ID which will be linked to the minimum rank number.
Settings.MinStaffRank = 3 --Minimum Staff Rank Required to use the system.

return Settings

I would highly recommend you learn how to code in Lua. Not to be rude but it’s quite clear that you have no clue on what your doing and that you have just copied the code from somewhere. There is nothing at all wrong with copying code as long as you understand it.

I am not going to give you the exact code to fix this because you need to learn but the below is what your doing wrong:

  1. You don’t have any if statements to check the user rank. You can’t just add a variable in and then expect it to do it for you.

  2. You don’t even get the rank out of the module script. You require the module script in the “Service” variable but don’t do anything with it.

Understand but I said I forgot. Please be a little bit more understanding. I’m requesting you don’t comment on this if you’re not going to help as this is a helping category. Not to be rude. Just the rules.

where is mainscript located I need it so I could get player

Saying you “forgot” something and you never knowing how to do it is completely different things. How do you suddenly forget how to do something so basic as an if statement? Also it’s clear that you don’t know how to code in Lua because you just sent over your code and expect people to give you working code.

I really don’t see how I am not understanding? I legit told you already exactly what the issue is and now all you need to do is edit the code which should be very simple to do if you know how to code in Lua.

Like I said rather then just diving straight in, learn the basics first. I am happy to help people and tell them what is wrong but I will not just give you the correct code.

How am I not helping? Please refer to my original message that tells you exactly what is wrong:

And you are correct yes it is for helping this category is however me just giving you correct code is not helping anyone to learn anything.

1 Like

It is located within the button.

It’s a local script meaning that as long as it’s in a place where local scripts run you can just use the player service and get the local player. I don’t see how the location of the script really affects anything.

I though it was a normal script because he said that its a mainscript

1 Like

That is far from the right answer, this is my notice to you to not comment on this thread anymore, as I’m not trying to start an argument. Please respect this request.

Ah I see makes sense as that could be confusing. It’s clear to me personally cuz of the usage of the UI button click thing.

I use localscript for all the buttons.

you didn’t saw serverscriptservice part?

1 Like

Oh shoot good point. Well that is super confusing XD.

Why is the buttonclicked event being used inside of a server script.

My bad sorry about that.

use this

local ServerScriptService = game:GetService(“ServerScriptService”)

local Service = require(ServerScriptService.StaffPanelSettings)

script.Parent.MouseButton1Click:Connect(function()

if game.Players.LocalPlayer:GetRankInGroup(Service.GroupId) > Service.MinStaffRank or game.Players.LocalPlayer:GetRankInGroup(Service.GroupId) == Service.MinStaffRank then
local Screen = script.Parent.Parent.Parent.Screen
Screen.Visible = false

local Screen = script.Parent.Parent.Parent.StaffPanel
Screen.Visible = true
end
end)

All my script have it as

script.Parent.MouseButton1Click:Connect(function()

local Screen = script.Parent.Parent.Parent.Screen
Screen.Visible = false

local Screen = script.Parent.Parent.Parent.MusicPlayer
Screen.Visible = true

end)

Please explain to me how? What I told you is exactly the correct way to fix the issue and is the right answer.

Don’t tell me what to do. I can comment on this post as much as I want as long as it follows the rules of the DevForum and you cannot stop me. I am also not at all arguing with you, I am just stating that you need to see the correct answer which I have already stated.

I’m trying to not fight you, please be respectful or I have to take action.

local ServerScriptService = game:GetService(“ServerScriptService”)

local Service = require(ServerScriptService.StaffPanelSettings)

script.Parent.MouseButton1Click:Connect(function()

if game.Players.LocalPlayer:GetRankInGroup(Service.GroupId) > Service.MinStaffRank or game.Players.LocalPlayer:GetRankInGroup(Service.GroupId) == Service.MinStaffRank then
local Screen = script.Parent.Parent.Parent.Screen.Staff
Screen.Visible = false

  local Screen = script.Parent.Parent.Parent.StaffPanel
  Screen.Visible = true

end
end)

Would the Screen = script.Parent.Parent.Parent.Screen.Staff
As the Parent is the Screen the Staff button should pop up if I do Screen.Staff