Well, by the looks of this it seems you’re only doing the LocalPlayer, have you tried looping every player in the game when they open the scoreboard/leaderboard?
As what @IAmTailerr said above, you are only applying this for the Local Player. To clone the template for everyone in the server, you need to loop through every player in the server.
Here is your updated code:
local Players = game:GetService("Players")
local Teams = game:GetService("Teams")
local templateFrame = script.Parent:WaitForChild("Template")
local function RedColor(frame)
frame.BackgroundColor3 = Color3.new(0.909804, 0.176471, 0.309804)
frame.Deaths.BackgroundColor3 = Color3.new(0.909804, 0.176471, 0.309804)
frame.Kills.BackgroundColor3 = Color3.new(0.909804, 0.176471, 0.309804)
frame.Username.BackgroundColor3 = Color3.new(0.909804, 0.176471, 0.309804)
end
local function BlueColor(frame)
frame.BackgroundColor3 = Color3.new(0.141176, 0.811765, 0.964706)
frame.Deaths.BackgroundColor3 = Color3.new(0.141176, 0.811765, 0.964706)
frame.Kills.BackgroundColor3 = Color3.new(0.141176, 0.811765, 0.964706)
frame.Username.BackgroundColor3 = Color3.new(0.141176, 0.811765, 0.964706)
end
local function cloneFrame(plrs, teamInstance)
local newFrame = templateFrame:Clone()
newFrame.Visible = true
newFrame.Username.Text.Text = plrs.Name
newFrame.Kills.Text.Text = plrs:WaitForChild("leaderstats").Kills.Value
newFrame.Deaths.Text.Text = plrs:WaitForChild("leaderstats").Deaths.Value
newFrame.Name = plrs.Name -- will be necessary when the player leaves
if teamInstance == Teams.Red then
newFrame.Parent = script.Parent:WaitForChild("RedTeamFrame")
RedColor(newFrame)
elseif teamInstance == Teams.Blue then
newFrame.Parent = script.Parent:WaitForChild("BlueTeamFrame")
BlueColor(newFrame)
end
plrs:WaitForChild("leaderstats").Kills:GetPropertyChangedSignal("Value"):Connect(function()
newFrame.Kills.Text.Text = plrs:WaitForChild("leaderstats").Kills.Value
end)
plrs:WaitForChild("leaderstats").Deaths:GetPropertyChangedSignal("Value"):Connect(function()
newFrame.Deaths.Text.Text = plrs:WaitForChild("leaderstats").Deaths.Value
end)
end
local function removeFrame(plr)
for _, descendants in pairs(script.Parent:GetDescendants()) do
if descendants:IsA("Frame") and -- I assime the 'Template' is a Frame
descendants.Name == plr.Name
then
descendants:Destroy()
end
end
end
for _, plrs in pairs(Players:GetPlayers()) do
local plrTeam = plrs.Team
cloneFrame(plrs, plrTeam)
end
Players.PlayerAdded:Connect(cloneFrame) -- this is for new players joining during the game
Players.PlayerRemoving:Connect(removeFrame) -- when the player leaves