Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Issue with Team BillboardGuis?

Asked by 8 years ago

So I recently ran into the problem of using PlayerToHideFrom in billboard guis...They do not let you use turple values (multiple data values) and are limited to 1 player. This is an extreme annoyance for me since if you wanted to only show a gui for a specific team players color above your head and not for other players of opposite colors. Any workaround for this? I'm open to all and any suggestions at this point, regardless of efficiency...

1 answer

Log in to vote
1
Answered by 8 years ago

Unfortunately, there is no way to make the PlayerToHideFrom property work for more than one player at this current time.

A workaround for this is to get all the players on the player's team, clone the BillboardGui to each teammate's PlayerGui and then set the BillboardGui's Adornee property to the player's head. That will make it so each teammate will see the player's BillboardGui, but it will be hidden from the enemy team's players.

A script in ServerScriptService with the following code should work (assuming the players' teams are set when the player enters the game):

local gui = nil --You want to change nil to the BillboardGui you created. If you haven't made one yet, create one in ReplicatedStorage and then reference it. replacing nil, here.

game.Players.PlayerAdded:connect(function(plr) --When a new player is added.
    plr.CharacterAdded:connect(function(char) --When a new player's character is added or respawned.
        repeat wait() until char --Waits for the character to load.
        for i,v in pairs(game.Players:GetPlayers()) do --Gets all the players in the game.
            if v.TeamColor == plr.TeamColor then --Check to see if the current player's TeamColor is equal to the new player's TeamColor.
                local bg = gui:Clone() --Clone the GUI.
                bg.Parent = v:WaitForChild("PlayerGui") --Wait until the PlayerGui is available before parenting the BillboardGui.
                bg.Adornee = char:WaitForChild("Head") --Adornees the BillboardGui to the player's head when it's available so the teammates can see it.
            end
        end
    end)
end)

I hope my answer helped you. If it did, be sure to accept it.

Ad

Answer this question