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.
game.Players.PlayerAdded:connect(onPlayerRespawned) function onPlayerRespawned(newPlayer) wait(1) if newPlayer.Name == "AthenaPerson" then gui=Instance.new("BillboardGui") gui.Parent=newPlayer.Character.Head gui.Adornee=newPlayer.Character.Head gui.Size=UDim2.new(2,0,2,0) gui.StudsOffset=Vector3.new(0,1,0) gui.AlwaysOnTop=true label=Instance.new("ImageLabel") label.Image="rbxassetid://819434834" label.Size=UDim2.new(0,100,0,100) label.Size=UDim2.new(1,0,1,0) label.Position=UDim2.new(0,0,-0.5,0) label.BackgroundTransparency = 1 label.Parent=gui end end function onPlayerEntered(newPlayer) newPlayer.Changed:connect(function (property) if (property == "Character") then onPlayerRespawned(newPlayer) end end) end
local players = game:GetService('Players') local group_id = 1 -- Group id -- Pre-made so the script doesn't have to keep doing it. local gui = Instance.new("BillboardGui") gui.Size = UDim2.new(2,0,2,0) gui.StudsOffset = Vector3.new(0,1,0) gui.AlwaysOnTop = true local label = Instance.new("ImageLabel") label.Image = "rbxassetid://819434834" label.Size = UDim2.new(0,100,0,100) label.Size = UDim2.new(1,0,1,0) label.Position = UDim2.new(0,0,-0.5,0) label.BackgroundTransparency = 1 label.Parent = gui -- Names here in a dictionary style table. local players_allowed = { player2 = true; player1 = true; ['spaced name'] = true; } local function player_joined(player) player.CharacterAdded:connect(function(character) if player:IsInGroup(group_id) or players_allowed[player.Name:lower()] then local gui_clone = gui:Clone() local head = character:WaitForChild("Head") -- This is the key part. -- Parent it to the PlayerGui, so that it's only visible to that player -- Adornee it to their head. gui_clone.Parent = player:WaitForChild("PlayerGui") -- Setting the Adornee RIGHT after it's parented seems to fail after re-loading? -- Delay to fix. delay(.1, function() gui_clone.Adornee = head end) end end) end players.PlayerAdded:connect(function(player) player_joined(player) end) for i,v in pairs(players:GetPlayers()) do player_joined(v) end
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;
local player = game.Players.LocalPlayer local GUI = --Where this billboardgui is and specifically the object, (Textlabel, TextButton, etc.) if player.Name == "Name" then GUI.Visible = true 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.