Owner and friend only GUI

I have a GUI I want only to be visible on certain players screen that i type there username in the script somewhere like
—PeopleCanSeeGUi = “Friend 1”, “Me”

2 Likes

No I don’t want it to be people on my friends list can see it

2 Likes

You can do

If player.Name = "PlayersName" or player.Name = "PlayersName" then

- rest of code here
1 Like

Can I keep adding ors? Or no I cant

1 Like

You can add as many or’s as you want

2 Likes

This means every player can see it but only people I put can use it?

1 Like

You can also do

// Function of instance Player
bool IsFriendsWith(int UserId)
4 Likes

I really only want the selected people to even see the GuI

I don’t want people from my friends list either

You can make it visible to only the players you put in the statement

Ok but how do I do that though

Using th every first script you provided me

In a local script inside you GUI you can put

local player = game.Players.LocalPlayer
if player.Name == "PlayerName" or player.Name= = "PlayerName" then

script.Parent.Enabled = true
end

And set the GUI enabled to false

1 Like

Dosent that mean if one of the players on the list joins the entire server can see it?

1 Like

It’s not good practise to use the players names, because they can change, use their Ids

1 Like

Nope only the player on the list can see the GUI.

How do I do this instead? 3000

I think I’m just going to use names

-- Method one, using IsFriendsWith
-- ServerScript

game.Players.PlayerAdded:Connect(function(Player)
     if Player:IsFriendsWith(YourUserId) then
         -- Do somethin
     else
         -- Do something else
      end
end)

-- Method 2, using Ids

local Whitelisted = {"List of userids"}
game.Players.PlayerAdded:Connect(function(Player)
     for _, v in pairs(Whitelisted) do
          if Player.UserId == v then
               -- Do something
          else
               -- Do something else
          end
     end
end)

4 Likes

Where do I put this in my GUI (30character)