Uh, im developing a leaderboard but i've got an error saying; "LeaderboardHandler:22: attempt to index string with 'Text'
How do i prevent this from happening?
01 | local DataStoreService = game:GetService( "DataStoreService" ) |
02 | local WinsLeaderboard = DataStoreService:GetOrderedDataStore( "WinsLeaderboard" ) |
03 |
04 | local function updateLeaderboard() |
05 | local success, errorMessage = pcall ( function () |
06 | local Data = WinsLeaderboard:GetSortedAsync( false , 5 ) |
07 | local WinsPage = Data:GetCurrentPage() |
08 | for Rank, data in ipairs (WinsPage) do |
09 | local userName = game.Players:GetNameFromUserIdAsync( tonumber (data.key)) |
10 | local NameX = userName |
11 | local Cash = data.value |
12 | local isOnLeaderboard = false |
13 | for i, v in pairs (workspace.GlobalLeaderboard.LeaderboardGUI.Holder:GetChildren()) do |
14 | if v.Player.Text = = NameX then |
15 | isOnLeaderboard = true |
Your problem is that you have an instance named “Name” You cant call it like that;
You should either do newLbFrams[“Name”].Text
to get the instance or you should just name it “name” instead.
Right now its trying to get to its name and then find another property called “Text” which doesnt exist.