This GUI wont work

Hello, today I am making a script that will only allow certain people access to a button.
It is not working.

Here is the local script

local MainFrame = script.Parent.MainFrame
local OpenButton = script.Parent.OpenPanel
local plr = game.Players.PlayerAdded
local GroupSerivce = game:GetService("GroupService")
local GroupID = 3757537
local RankToUse = 175

MainFrame.Visible = false
OpenButton.Visible = false

if plr:GetRankInGroup(GroupID) >= RankToUse then
	OpenButton.Visible = true
	print("Yay! You can see!")
	
else
	OpenButton.Visible = false
	print("Opps Cant see!!")
end

OpenButton.MouseButton1Click:Connect(function(open)
	MainFrame.Visible = true
end)

Are there any error or outputs at all?

Nope, the output is clear (need to write more)

You are saying this is a local script? If so, couldn’t you use:

local plr = game.Players.LocalPlayer

Okay, I did that but now it lets me see the button when I am not the required rank.

Would you mind printing out the rank?

wdym, printing out the rank? Could you give an example.

local Button = script.Parent

local plr = game:GetService(“Players”).LocalPlayer

local groupID = “IDHERE”

if plr:GetRoleInGroup(5768377) == “Owner” then

print(“You are the owner”)

Button.Visible = true

end

this wouldn’t work in my case because I am trying to make it mod(175) plus

I mean printing whatever :GetRankInGroup returns

I dont think I have ever done that. Do you mind giving an example how?

Here:

local rank = plr:GetRankInGroup(GroupID)
print(rank)

local plr = game:GetService(“Players”).LocalPlayer

local groupID = 5768377

local rank = plr:GetRankInGroup(groupID)

if rank > 175 and rank < 256 then

print(“Pass”)

end

Im am very dumb. It seems when I was testing instead of putting 255 I was putting 250 witch I still meant the requirement for.

Sorry for any trouble I cause lol.

local Gui = script.Parent
local MainFrame = Gui:WaitForChild("MainFrame")
local OpenButton = Gui:WaitForChild("OpenPanel")
local Player = game.Players.LocalPlayer
local GroupID = 3757537
local RankToUse = 1 --1 just checks if a member of group

MainFrame.Visible = false
OpenButton.Visible = false

if Player:GetRankInGroup(GroupID) >= RankToUse then
	OpenButton.Visible = true
	print("Yay! You can see!")
else
	OpenButton.Visible = false
	print("Opps Cant see!!")
end
OpenButton.MouseButton1Click:Connect(function(open)
	MainFrame.Visible = true
end)