Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make billboardguis visible only to a specific team?

I'm currently working on a murder/mafia style game and am trying to make a marker icon that shows the killer where the players are (allowing him to see if they're behind a wall for example)

So far I've created a script in the ServerScriptService that clones a billboardgui (holding the icon and set to "AlwaysOnTop") team from the ServerStorage and parents it to the head of the player on the "innocent" team (it does this to every player on that team)

Here's the relevant bit of code:

local victims = game.Teams["Innocent"]:GetPlayers()
			
			for _,player in pairs(victims) do
				local killerweaponcloned = killerweapon:Clone()
				killerweaponcloned.Parent = player.Backpack
				local clonedvictimicon = victimicon -- game:GetService("ServerStorage"):WaitForChild("VictimIcon")
				clonedvictimicon.Parent = game.Workspace:WaitForChild(player.Name).Head
			end
		end

Currently these icons are visible to all teams. How do I go about making it so that the billboardgui icon in each innocent player is only visible to players in my "killer" team?

2 answers

✓ Accepted answer

What you have to do is run an if statement an check wether the conditions are true. For example the player team.

Here's a script that should work:

local victims = game.Teams["Innocent"]:GetPlayers()

            for _,player in pairs(victims) do
local victims = game.Teams["Innocent"]:GetPlayers()
            for _,player in pairs(victims) do
                local killerweaponcloned = killerweapon:Clone()
                if v.TeamColor == BrickColor.new( "Bright Blue") then 
                local killerweaponcloned = killerweapon:Clone()
                killerweaponcloned.Parent = player.Backpack
                local clonedvictimicon = victimicon -- game:GetService("ServerStorage"):WaitForChild("VictimIcon")
                clonedvictimicon.Parent = game.Workspace:WaitForChild(player.Name).Head
            end
        end
end

Here's a simplified example script

wait (5)
local StarterGUI = game.ServerStorage.ScreenGui --this is your surfaceGui nested inside a screengui inside serverstorage
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")

Players.PlayerAdded:Connect(function(player)
	wait (0.5)
	local SGC = StarterGUI:Clone() --we clone the gui
	
	if player.Team.Name == "Bright blue Team" then --and check if the player is on the right team and if he is we parent the clone to his PlayerGui folder allowing only him to see the screen gui
	SGC.Parent = player.PlayerGui
	else print "wrong team"
	end
end)

Hope this helps

This discussion is preserved as it was. New answers, comments, and votes are closed.