Group script help

Hii! I’m trying to make this script to work only for higher group ranks.

I mean when they type the command, it works only for higher group ranks and not for low ranks.

Script:
function onChatted(msg, speaker)

    source = string.lower(speaker.Name)
    msg = string.lower(msg)
    -- Note: This one is NOT caps sensitive

    if msg == "!opendoor1", then
        script.Parent.Transparency = 1
        script.Parent.CanCollide = false
    if msg == "!closedoor1", then
        script.Parent.Transparency = 0
        script.Parent.CanCollide = true
    end
end

function onPlayerEntered(newPlayer)
        newPlayer.Chatted:connect(function(msg) onChatted(msg, newPlayer) end) 
end
 
game.Players.ChildAdded:connect(onPlayerEntered)

Might wanna look at this :thinking:

function onChatted(msg, speaker)

    source = string.lower(speaker.Name)
    msg = string.lower(msg)
    -- Note: This one is NOT caps sensitive

    if msg == "!opendoor1" and speaker:GetRankInGroup(GROUP_ID) >= MINIMUM_RANK then
        script.Parent.Transparency = 1
        script.Parent.CanCollide = false
    if msg == "!closedoor1" and speaker:GetRankInGroup(GROUP_ID) >= MINIMUM_RANK then
        script.Parent.Transparency = 0
        script.Parent.CanCollide = true
    end
end

function onPlayerEntered(newPlayer)
        newPlayer.Chatted:connect(function(msg) onChatted(msg, newPlayer) end) 
end
 
game.Players.ChildAdded:connect(onPlayerEntered)

Probably something like this where GROUP_ID is the ID of your group and MINIMUM_RANK is the value of the rank (for example group holder would be 255)