@SilentSuprion (SilentSuprion) posted a new topic, subject "What's wrong with my leaderboard gui script?". It read:

   I'm not sure what's wrong with my script. When I use the same script on a different leader stat(Cash) it works. But not with Lvl.  
    Please help, have a great day.
    
    Output:  
    Players.Rapideed.PlayerGui.BarGui.BackgroundBoarderFrame.LvlBoarderFrame.TextLabel.LocalScript:3: attempt to index nil with ‘Value'
    
    Script:  
    while wait() do
    [code] 
        local player = game.Players.LocalPlayer
        
        script.Parent.Text = "Lvl: "..player:WaitForChild("leaderstats"):FindFirstChild("Lvl").Value
        
        end
    [/code]

After which, @EmbatTheHybrid (Embat) added

    You'd have to also use `WaitForChild` on the Lvl value, also, it's better if you use the `Changed` event for BaseValues in your case instead of a loop that changes the text since an event will run when a condition has been met, something like this
    [code] 
        local player = game:GetService("Players").LocalPlayer
        
        local stats = player:WaitForChild("leaderstats")
        local level = stats:WaitForChild("Lvl")
        
        script.Parent.Text = "Lvl: " .. level.Value
        
        level.Changed:Connect(function(newVal)
        	script.Parent.Text = "Lvl: " .. newVal
        end)
        
    [/code]
    
    `Changed` in the cause of BaseValues such as Intvalues, StringValues, etc, return the new value in the BaseValue it is connected to, hence why I use it there

@SilentSuprion (SilentSuprion) replied

    It should work, but it doesn't match. The error says  
    Infinite yield possible on 'Players.Rapideed.leaderstats:WaitForChild(“Lvl”)  
    And why does it work for cash but not lvl. It's the same value and script, just different names.

After which, @EmbatTheHybrid (Embat) added

    Did you remember to insert something called `Lvl` in your leaderstats? That's happenign beause it couldn't find it, could be that or a typo

So @Va_riable (var) replied

    Check the spelling of the script.

So @SilentSuprion (SilentSuprion) replied

    Oh sorry it's my fault I named it “Level” instead of “Lvl.” Thanks for your help, have a great day.

To which @EmbatTheHybrid (Embat) replied

    Anytime! If you have anymore issues don't be afraid to make another post!


{'source': 'discourse', 'url': 'https://devforum.roblox.com/t/whats-wrong-with-my-leaderboard-gui-script/1189248', 'title': "What's wrong with my leaderboard gui script?", 'views': 126, 'has_accepted_answer': True, 'word_count': 286, 'like_count': 2, 'reply_count': 5, 'participant_count': 3, 'posts': 7, 'tags': '', 'author': '@SilentSuprion (SilentSuprion)', 'participants': '@SilentSuprion (SilentSuprion), @EmbatTheHybrid (Embat), @Va_riable (var)', 'image_url': [None], 'created_at': '2021-04-26T15:15:19.410Z', 'last_posted_at': '2021-04-26T15:28:14.835Z'}