essentially im trying to make a leaderboard whereby players names are under a text label, either pirates or marines, everything works however when I try to change the person faction it doesn’t update to the leaderboard. i tried making it so that an event fires from the server whenever the players faction changes and then it updates it to all clients. the issue is that the layout value doesn’t change to 4, it stays at 2. how would I fix this?
local plr = game:GetService("Players").LocalPlayer
local rs = game:GetService("ReplicatedStorage")
local event = rs.RemoteEvents.FactionChanged
function update()
for i, v in pairs(script.Parent.PlayersFrame:GetChildren()) do
if v:IsA("TextLabel") and v.Name ~= "PirateList" and v.Name ~= "MarineList" then
v:Destroy()
end
end
--
for i, player in pairs(game.Players:GetChildren()) do
local leaderbaord = script.Parent
local PlayerListFrame = leaderbaord.PlayersFrame
local playertextclone = rs.Gui:WaitForChild("PlayerName"):Clone()
if plr.leaderstats.Faction.Value == "Pirate" or "None" then
playertextclone.Parent = PlayerListFrame
playertextclone.LayoutOrder = 2
playertextclone.Text = player.Name
playertextclone.Visible = true
elseif plr.leaderstats.Faction.Value == "Marine" then
playertextclone.Parent = PlayerListFrame
playertextclone.LayoutOrder = 4
playertextclone.Text = player.Name
playertextclone.Visible = true
end
end
end
update()
game.Players.PlayerAdded:Connect(function()
update()
end)
game.Players.PlayerRemoving:Connect(function()
wait(2)
update()
end)
event.OnClientEvent:Connect(function()
print("FactionChangerWorks")
update()
end)