Hello people.
I'm trying to make a Roblox game with a leaderboard but it isn't going great. I'm not getting any errors but the script is still not working. By not working I mean nothing pops up on the Leaderboard. Nothing pops up in the console when I go into the game, only if I test it in Roblox Studio. Here is the game: https://www.roblox.com/games/6697835891/Legit-Parkour
Heres the code:
local DataStoreService = game:GetService("DataStoreService")
local Coins = DataStoreService:GetOrderedDataStore("Coins")
local function updateLeaderboard()
local success, errorMessage = pcall(function()
local Data = Coins:GetSortedAsync(false, 5)
local CoinsPage = Data:GetCurrentPage()
for Player, data in ipairs(CoinsPage) do
local userName = game.Players:GetNameFromUserIdAsync(tonumber(data.key))
local Name = userName
local Coins = data.value
local isOnLeaderboard = false
for i, v in pairs(game.Workspace.Leaderboard.SurfaceGui.Holder:GetChildren()) do
if v.Player.Text == Name then
isOnLeaderboard = true
break
end
end
if Coins and isOnLeaderboard == false then
local newLBFrame = game.ReplicatedStorage:WaitForChild("LeaderboardFrame"):Clone()
newLBFrame.Player.Text = Name
newLBFrame.Coins.Text = Coins
newLBFrame.Position = UDim2.new(0, 0, newLBFrame.Position.Y.scaale + (.08 * #game.Workspace.Leaderboard.SurfaceGui.Holder:GetChildren()), 0)
newLBFrame.Parent = game.Workspace.Leaderboard.SurfaceGui.Holder
end
end
end)
if not success then
print(errorMessage)
end
end
while true do
for _, Player in pairs(game.Players:GetPlayers()) do
Coins:SetAsync(Player.userId, Player.leaderstats.Coins.Value)
end
for _, frame in pairs(game.Workspace.Leaderboard.SurfaceGui.Holder:GetChildren()) do
frame:Destroy()
end
updateLeaderboard()
print("Updated LB")
wait(10)
end
Here is what the Roblox Studio's console, output or whatever says after I start playing then stopped
**14:58:55.711 Legit Parkour @ 30 Apr 2021 14:58 auto-recovery file was created - Studio - C:/Users/Kasutaja/Documents/ROBLOX/AutoSaves
14:59:04.829 Infinite yield possible on 'ReplicatedStorage:WaitForChild("LeaderboardFrame")' - Studio 14:59:04.829 Stack Begin - Studio 14:59:04.829 Script 'ServerScriptService.LeaderbOard', Line 20 - Studio - LeaderbOard:20 14:59:04.829 Script 'ServerScriptService.LeaderbOard', Line 5 - function updateLeaderboard - Studio - LeaderbOard:5 14:59:04.829 Script 'ServerScriptService.LeaderbOard', Line 43 - Studio - LeaderbOard:43 14:59:04.829 Stack End - Studio 15:00:10.887 The Parent property of
is locked, current parent: NULL, new parent ReplicatedFirst - Studio 15:00:10.888 Stack Begin - Studio 15:00:10.888 Script 'Model.MainModule', Line 20 - Studio 15:00:10.888 Stack End - Studio 15:00:10.848 Disconnect from ::ffff:127.0.0.1|61122 - Studio**
Thank you!

3 comments
im new and i dont understand the "Setting Parent" part. im not sure if spoonfeeding is allowed here but should i delete line 39?
i got it fixed, the issue was that there was no LeaderboardFrame in replicatedstorage
you should make this correct.