How would I change the text of the rankgui based on the leaderstats

I want to change the text for the rankgui based on the players leaderstats and ho much theyhave. Can anyone tell me how to do this

I have the rankgui/billboardgui in the ServerStorage and I have the script inside of ServerScriptService

Here is the script:

local rankgui = game:GetService(“ServerStorage”):WaitForChild(“RankGui”)

game.Players.PlayerAdded:Connect(function(player)

player.CharacterAdded:Connect(function(character)

local clonegui = rankgui:Clone()

clonegui.TextLabel.Text = “NoRank”

clonegui.TextLabel.TextColor3 = Color3.fromRGB(255, 170, 0)

clonegui.Parent = game.Workspace:WaitForChild(player.Name).Head

end)

end)

The script below should work. (only an example)

local rankgui = game.ServerStorage:WaitForChild("RankGui");

game.Players.PlayerAdded:Connect(function(player)
local folder = Instance.new("Folder", player);
folder.Name = "Leaderstats";
local cashvalue = Instance.new("NumberValue", folder);
cashvalue.Name = "Cash";
cashvalue.Value = 10
spawn(function()
cashvalue.Value = cashvalue.Value + 10;
end)
player.CharacterAdded:Connect(function(char)
local clonegui = rankgui:Clone()
clonegui.TextLabel.Text = "Rank 1";
clonegui.TextLabel.TextColor3 = Color3.fromRGB(255, 170, 0);
clonegui.Parent = char.Head;
clonegui.Adornee = char.Head;
spawn(function()
while char and clonegui do
wait()
if player:FindFirstChild("Leaderstats").Cash.Value < 50 then
clonegui.TextLabel.Text = "Rank 1"
elseif player:FindFirstChild("Leaderstats").Cash.Value >= 50 then
clonegui.TextLabel.Text = "Rank 2"
end
end
end)
end)
end)

I have made a community tutorial earlier for something like this.