Show UI to specific people that are in the group when someone runs a command

  1. What do you want to achieve? Keep it simple and clear!
    I would like a UI that shows to a specific group of people that are in the table when someone runs a command (it basically calls admins, but it’s group synced)

  2. What is the issue? Include screenshots / videos if possible!
    When I try to make the frame visible to those players only, it shows me this error:
    ServerScriptService.Admin:54: attempt to index nil with 'Admin'

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I looked over solutions on the Developer Hub and other script helping websites, but I couldn’t find a fix to my problem

This is my script:

commands.callmr = function(sender, args)

    local playerCalled = sender.Name

    if playerCalled then

        local plrCalled = findPlayer(playerCalled)

        if plrCalled then

            local mrmembers = {}

            for _, x in pairs(Players:GetPlayers()) do

                if x:GetRankInGroup(groupid) >= minrank then

                    table.insert(mrmembers, x.Name)

                    local msg = table.concat(mrmembers, " ")

                    print(msg)

                    for _, v in pairs(mrmembers) do

                        print(v)

                        v.PlayerGui.Admin.CallMR.Visible = true
                        v.PlayerGui.Admin.CallMR.NameLabel.Text = "test"
                        v.PlayerGui.Admin.CallMR.NameLabel.Text = "test2"

                    end
                end
            end
        end
    end
end

image

What’s more curious to me is why the table doesn’t have any elements in it but do proofread your code a little bit. Your mrmembers is populated with strings of player names and then later when you loop over that table you’re trying to access a string’s PlayerGui which doesn’t exist. PlayerGui is a child of the player so your table should be consisting of players instead.

I fixed it somehow, thank you for the help anyways