How to create a billboard gui that is visible/invisible to certain players?

Recently I’ve been trying to figure out how to create a script that would allow certain players to view a billboard gui and other not to.

Here’s what I’ve gotten so far, I’m not really sure how to approach this as I’ve never used billboards before.

Local Script

local list = {"VaIuent"}
local player = game.Players.LocalPlayer

for _,v in pairs(list) do
	if v == player.Name then
		script.Parent.Enabled = true
	end
end

To go in more depth of what I’m trying to achieve, in short, I’m trying to make a AFK Billboard UI that will only show to certain members in a group, and if they are not in the group then they cannot view it. Note, I am using a billboard gui like I have mentioned before.

And like always, thanks in advance for any help! :grinning_face_with_smiling_eyes:

1 Like

Hello!

For Checking if player is in group you have to use this i think

local list = {"VaIuent"}
local player = game.Players.LocalPlayer

for _,v in pairs(list) do
   if game.Players:FindFirstChild(v):IsInGroup(0) then      -- your group id here              
      if v == player.Name then
		script.Parent.Enabled = true
	end   
   end
end

i think something like this is the right choise

1 Like

you would need to handle this on the server side. have the server fire a remoteevent to the individual players that can see the billboard gui. the players would then construct the billboard gui and display it within a localscript.

local remoteEvent = replicatedStorage.remEvent

local plrsWhoCanSee = {
for _, plr in pairs(plrsWhoCanSee) do
    remoteEvent:FireClient(plr)
end
local remoteEvent = replicatedStorage.remEvent

remEvent.OnClientEvent:Connect(function()
    -- create/clone billboard gui and then parent it to character, or whereever u want
end)
1 Like

I already have a script that is replicating it within each player, if I put the local script inside the billboard GUI, would that still work?

Thank you for the help but, I am aware of the :IsInGroup() function, but that’s not exactly what I was asking for. Apologies if I may have worded it wrong.

when u said script, you meant a server-sided script? don’t quite get your reply. mind rephrasing?

Yes, I already have a serer script that is replicating the UI into each player, upon them joining.

alright then, when you want to show a player’s afk tag, you can use a remoteevent and loop thru the list of players you want to make visible to and call :FireClient()
the client would then pick it up and make the afk player’s tag visible via a localscript

local afkPlr
for _, plr in pairs(plrToShow) do
    remote:FireClient(plr, afkPlr)
end
--- client side
remote.OnClientEvent:Connect(function(afkPlr)
    afkPlr.Character.AFKTag.Enabled = true
end)

afkPlr returns as nil though. Unsure as of why.

you need to set it to your player, i was just writing “demo” code, it isn’t full by any means

is everything ok? didnt hear from you for quite some time @VaIuent

Yes, though I tried your idea and I could not get it to work in the slightest. What I did however find was BoolValue’s to be quite useful, as they can be changed Client side and Server side. So this was actually the solution for me. Here is the code I used:

Server Script

local nametag = script:WaitForChild("AFKGui")
c = 1
local event = game.ReplicatedStorage.Events.ShowGui
local list = {"VaIuent"}

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		c = nametag:Clone()
		c.Enabled = false
		c.Parent = character.Head
	end)
end)

game.Players.PlayerAdded:Connect(function(pls)
	event:FireClient(pls)
end)

Local Script

local player = game.Players.LocalPlayer
local list = {"VaIuent"}
local allowed = script.Parent:WaitForChild("Allowed")
local rp = game:GetService("ReplicatedStorage")
local breakloop = rp.Bools.BreakLoop

game.ReplicatedStorage.Events.ShowGui.OnClientEvent:Connect(function()
for _,i in pairs(game.Players:GetChildren()) do
	for _,v in pairs(list) do
		if player.Name == v then
			allowed.Value = true
			print(i)
			if allowed then
				i.Character.Head.AFKGui.Enabled = true
			else
				i.Character.Head.AFKGui.Enabled = false
			end
		end
		end
	end
	--[[if breakloop.Value == true then
		break
	end	--]]
	end)

print("loop broken")

oo ok that’s kind of nice, good to know it’s already working haha

Yup no problem, use it if you’d like! :grinning_face_with_smiling_eyes: