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”
No I don’t want it to be people on my friends list can see it
You can do
If player.Name = "PlayersName" or player.Name = "PlayersName" then
- rest of code here
Can I keep adding ors? Or no I cant
You can add as many or’s as you want
This means every player can see it but only people I put can use it?
You can also do
// Function of instance Player
bool IsFriendsWith(int UserId)
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
Dosent that mean if one of the players on the list joins the entire server can see it?
It’s not good practise to use the players names, because they can change, use their Ids
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)
Where do I put this in my GUI (30character)