I was wondering how to make this script visible to only people/group that I set it to. I've worked on this for like 3 hours now and can't figure it out.
01 | game.Players.PlayerAdded:connect(onPlayerRespawned) |
02 | function onPlayerRespawned(newPlayer) |
03 | wait( 1 ) |
04 | if newPlayer.Name = = "AthenaPerson" then |
05 | gui = Instance.new( "BillboardGui" ) |
06 | gui.Parent = newPlayer.Character.Head |
07 | gui.Adornee = newPlayer.Character.Head |
08 | gui.Size = UDim 2. new( 2 , 0 , 2 , 0 ) |
09 | gui.StudsOffset = Vector 3. new( 0 , 1 , 0 ) |
10 | gui.AlwaysOnTop = true |
11 | label = Instance.new( "ImageLabel" ) |
12 | label.Image = "rbxassetid://819434834" |
13 | label.Size = UDim 2. new( 0 , 100 , 0 , 100 ) |
14 | label.Size = UDim 2. new( 1 , 0 , 1 , 0 ) |
15 | label.Position = UDim 2. new( 0 , 0 ,- 0.5 , 0 ) |
01 | local players = game:GetService( 'Players' ) |
02 | local group_id = 1 -- Group id |
03 |
04 | -- Pre-made so the script doesn't have to keep doing it. |
05 | local gui = Instance.new( "BillboardGui" ) |
06 | gui.Size = UDim 2. new( 2 , 0 , 2 , 0 ) |
07 | gui.StudsOffset = Vector 3. new( 0 , 1 , 0 ) |
08 | gui.AlwaysOnTop = true |
09 | local label = Instance.new( "ImageLabel" ) |
10 | label.Image = "rbxassetid://819434834" |
11 | label.Size = UDim 2. new( 0 , 100 , 0 , 100 ) |
12 | label.Size = UDim 2. new( 1 , 0 , 1 , 0 ) |
13 | label.Position = UDim 2. new( 0 , 0 ,- 0.5 , 0 ) |
14 | label.BackgroundTransparency = 1 |
15 | label.Parent = gui |
You can do game.Players.LocalPlayer
. Then if the player's name is specifically "Name" then make the GUI Visible. Now what i suggest you doing is to create the GUI first and make sure the GUI is invisible. Then do this code;
1 | local player = game.Players.LocalPlayer |
2 | local GUI = --Where this billboardgui is and specifically the object, (Textlabel, TextButton, etc.) |
3 |
4 | if player.Name = = "Name" then |
5 | GUI.Visible = true |
6 | end |
Make sure this is a localscript in StarterPlayerScripts
This will make it visible to the LocalPlayer. Therefore no one else can see it.
If I helped then please accept answer and upvote.