I'm trying to make a script where a Billboard GUI tags you when you die. Of course, it has to be visible only to the specified team.
I can understand what it's saying but I do not know where to start editing. Would I replace the "local group_id" with the team color/name?
local players = game:GetService('Players') local group_id = 1 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 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") gui_clone.Parent = player:WaitForChild("PlayerGui") 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
Hi!
Players have a Team property that specifies the name of the team they are on (returns nil if they're not in a team). On line 28 where it sees if the player is in the group, it can just be replaced with "if player.Team == team then".
You can just change the "team" variable to the name of the team. Sounds like you dont need the players_allowed variable since you are only assorting by teams, so that can be removed. Lastly, since you want the billboard to appear when the character dies, you can simply change the event from "CharacterAdded" to "CharacterRemoving" on line 27.
local players = game:GetService('Players') local team = --Put the name of the team here 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 local function player_joined(player) player.CharacterRemoving:connect(function(character) --The character has died. if player.Team == team then --If player is in the team then local gui_clone = gui:Clone() local head = character:WaitForChild("Head") gui_clone.Parent = player:WaitForChild("PlayerGui") 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
Make sure to Accept Answer if this was the answer you're looking for! Comment below if you have any questions/concerns!