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

Team Change that Influence UI change?

Asked by 2 years ago

I was new to scripting and I was trying to make a script where the player change team, the billboard gui changes too, but I can't seem to figure it out.

This is a ServerScript inside a ServerScriptService

local ServerStore = game:GetService("ServerStorage")
local TeamService = game:GetService("Teams")

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        for i, v in pairs(game:GetService("Players"):GetChildren()) do
            if v.Team.Name == "Free Stalker" then
                local tag = ServerStore:FindFirstChild("FreeStalker"):Clone()
                if tag:IsA("BillboardGui") then
                    tag.Parent = char.Head
                    tag.TextLabel.Text = player.DisplayName
                end
            elseif v.Team.Name == "Team _" then
                local tag = ServerStore:FindFirstChild("ToBeChangedTeam"):Clone()
                if tag:IsA("BillboardGui") then
                    tag.Parent = char.Head
                    tag.TextLabel.Text = player.DisplayName
                end
            end
        end
    player:GetPropertyChangedSignal("Team"):Connect(function()
            if char:WaitForChild("Humanoid").Health == 0  then
                for i, v in pairs(char.Head:GetChildren()) do
                    if v:IsA("BillboardGui") then
                        v:Destroy()
                    end
                end
            end
        end)
    end)
end)

Answer this question