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

I was wondering how to make the billboard GUI show to mulitple people only?

Asked by 7 years ago

I attempted to ask this question earlier yesterday, and I thought it was answer but.. the thing only shows to you, not to the others. The purpose of the script is for a squad system, and only your squad can see you.

local players = game:GetService('Players')
local group_id = 3214011 -- 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://819434580"
    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 = {
    HarbingerIce = true;
    VigilantIce = true;
    chief4587234 = true;
    CelestialIce = true;
    JordyIce = true;
    evilcrossbow = true;
    FleetAdmiralIce = 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

1 answer

Log in to vote
0
Answered by
RootEntry 111
7 years ago

You could look at the wiki for GetPlayersFromTeam() function or something.

Ad

Answer this question