How can I get a button that only works with the minimum rank in a group?

I am trying to make a button that only works when the player is in the group. I kinda looked through the DevHub, and mixed some code with another video that showed me how to work with group IDs and minimum ranks. Here is the code I have.

local clickDetector = script.Parent.ClickDetector
local exitDoor = game.Workspace.entrancedoor
local groupId = 5879349
local minRank = 253

clickDetector.MouseClick:Connect(function()
game.Players.PlayerAdded:Connect(function(Player)
if Player:GetRankInGroup(groupId) == >= minRank then
exitDoor.glassdoor.Transparency = 1
exitDoor.glassdoor.CanCollide = false
end
end)
end)

:baby:t6:

local clickDetector = script.Parent.ClickDetector
local exitDoor = game.Workspace.entrancedoor
local groupId = 5879349
local minRank = 253

clickDetector.MouseClick:Connect(function(Player)
    if Player:GetRankInGroup(groupId) >= minRank then
       exitDoor.glassdoor.Transparency = 1
       exitDoor.glassdoor.CanCollide = false
    end
end)
1 Like

Thank you very much for the help on this project.