You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Would like for a test label to be over the top of the imagelabel to show leader stats over the players image. currently this works but there are two issues. first is that that textlabel instance sits next to the image label not on top of it ( will make the textlabel transparent later so the image can be seen if the textlabel is over the top )
Also the leaderstat will only update once as it is only adding the image and text label ( not in a loop ) true while true do etc… for the leaderstats line but cant work out how update the tectlabel with the script getting jammed up in a loop to update the leader stat. Thank you in advance :
local Enumeration = Enum
local Game = game
local Script = script
local Players = Game:GetService(“Players”)
local Teams = Game:GetService(“Teams”)
local GreenTeam = Teams.Green
local BlueTeam = Teams.Blue
local TeamsGui = Script:FindFirstAncestorOfClass(“ScreenGui”)
local GreenTeamFrame = TeamsGui:FindFirstChild(“GreenTeamFrame”)
local BlueTeamFrame = TeamsGui:FindFirstChild(“BlueTeamFrame”)
local TeamFrames = {[GreenTeam] = GreenTeamFrame, [BlueTeam] = BlueTeamFrame}
for _, Team in ipairs(Teams:GetTeams()) do
local function OnTeamPlayerAdded(Player)
print(TeamFrames[Player.Team])
local TeamFrame = TeamFrames[Player.Team]
if not TeamFrame then return end
local PlayerImage = TeamFrames[Player.Team]:FindFirstChild(Player.Name)
local PlayerImage2 = TeamFrames[Player.Team]:FindFirstChild(Player.Name)
if not PlayerImage then
local Success, Result = pcall(function() return Players:GetUserThumbnailAsync(Player.UserId, Enumeration.ThumbnailType.HeadShot, Enumeration.ThumbnailSize.Size420x420) end)
if not (Success and Result) then warn(Result) return end
PlayerImage = Instance.new("ImageLabel")
PlayerImage.Name = Player.Name
PlayerImage.Size = UDim2.new(.1, 0, 1, 0)
PlayerImage.Image = Result
PlayerImage2 = Instance.new("TextLabel")
PlayerImage2.Name = Player.Name
PlayerImage2.Size = UDim2.new(.1, 0, 1, 0)
PlayerImage2.Text= Player.Leaderstat.Kills.Value
PlayerImage.Parent = TeamFrames[Player.Team]
PlayerImage2.Parent = TeamFrames[Player.Team]
end
PlayerImage.BackgroundColor3 = Player.TeamColor.Color
end
local function OnTeamPlayerRemoved(Player)
local TeamFrame = TeamFrames[Team]
if not TeamFrame then return end
local PlayerImage = TeamFrame:FindFirstChild(Player.Name)
if PlayerImage then PlayerImage:Destroy() end
end
Team.PlayerAdded:Connect(OnTeamPlayerAdded)
Team.PlayerRemoved:Connect(OnTeamPlayerRemoved)
for _, Player in ipairs(Team:GetPlayers()) do
OnTeamPlayerAdded(Player)
end
end