I’m trying to make it so that the player with the most streak will get a crown above their head, and it changes the grown to the person with more streaks.
But the script doesn’t seem to work when I’m testing it with more than one person, but it does work when I’m testing it alone.
This is how I’ve gotten so far with my script
local crown = false
while true do
wait(1)
local function GetRichestPlayer()
local Players = game.Players:GetPlayers()
table.sort(Players, function(a,b)
return a.leaderstats.Streak.Value > b.leaderstats.Streak.Value
end)
return Players[1]
end
local RichestPlayer = GetRichestPlayer()
local Char = RichestPlayer.Character
if crown == true then
return
end
if Char then
local RP = game:GetService('ReplicatedStorage')
local crown = RP:FindFirstChild('Crown'):Clone()
crown.Parent = game.Workspace.StreakKing
crown.Name = RichestPlayer.Name
crown.CFrame = Char:WaitForChild('Head').CFrame * CFrame.new (0,2,0)
local weld = Instance.new('ManualWeld')
weld.Part0 = crown
weld.Part1 = Char:FindFirstChild('Head')
weld.C0 = weld.Part0.CFrame:toObjectSpace(weld.Part1.CFrame)
weld.Parent = weld.Part0
end
end