Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

LeaderboardHandler:22: attempt to index string with 'Text'?

Asked by 4 years ago

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?

01local DataStoreService = game:GetService("DataStoreService")
02local WinsLeaderboard = DataStoreService:GetOrderedDataStore("WinsLeaderboard")
03 
04local 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
View all 49 lines...

1 answer

Log in to vote
2
Answered by
iOwn_You 543 Moderation Voter
4 years ago
Edited 4 years ago

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.

0
I am pretty sure you can also use FindFirstChild("Name") or WaitForChild("Name"), but it's true. The script is referring to the property Name, not the child Name. LightningLIon58 49 — 4y
0
You could, but its shorter to write what I sent and you dont need findfirst or waitfor because its an instance created with studio, its surely there. iOwn_You 543 — 4y
Ad

Answer this question