i’m trying to make an placement system like first place second place etc
-- PlayerRelated
local AllPlayersDistance = {}
-- PlayerRelated
-- Instance Related
local Objetivo = game.Workspace.FirstStage.Coroa.CoroaCoroa.Position
-- Instance Related
-- Gui
local RankGui
local GuiToClone = game.ReplicatedStorage.Rank
local AllFramesOnGui
-- Gui
-- Remote
local InRound = game.ReplicatedStorage.InRound
-- Remote
-- Randoms
local low = math.huge
-- Randoms
InRound.Changed:Connect(function()
if InRound.Value == true then
local function UploadGui()
for i, v in pairs(game.Players:GetPlayers()) do
RankGui = v.PlayerGui:WaitForChild("Position").RankGui
AllFramesOnGui = RankGui:GetChildren()
for _, frame in ipairs(AllFramesOnGui) do
if frame:IsA("Frame") then
frame:Destroy()
print("Frames Destroyed!")
end
end
local Distance = v:DistanceFromCharacter(Objetivo)
AllPlayersDistance[v.Name] = Distance -- ["ETILUMINATI"] = Distance
table.sort(AllPlayersDistance)
for i, v in pairs(AllPlayersDistance) do
if v < low then
local FrameClone = GuiToClone:Clone()
FrameClone.PlayerName.Text = i
FrameClone.Parent = RankGui
low = v
print(low)
end
end
end
end
while true do
spawn(UploadGui)
wait(1)
end
end
end)
all working fine the player name go in this gui but it dont update it like i need to add the frame of the player who has the lowest distance first so it will fit on the gui