I have been trying to make a leaderboard and so far it has been working but I have one problem my values are not updating and I have yet to figure it out
here is my script –
local DataStored = game:GetService(“DataStoreService”)
local LeaderBoard1 = DataStored:GetOrderedDataStore(“RubyLeaderboard”)
local Run = game:GetService(“RunService”)
game.Players.PlayerAdded:Connect(function(plr)
local function Update()
local Succcess, errormessage = pcall(function()
local Data = LeaderBoard1:GetSortedAsync(false, 5)
local RapPage = Data:GetCurrentPage()
for rank, data in ipairs(RapPage) do
local UserName = plr.Name
local Name = UserName
local Rap = data.value
local IsOnLeaderboard = false
for i, v in pairs(game.Workspace.Leaderboard1.SurfaceGui.Holder:GetChildren()) do
if v.Player.Text == Name then
IsOnLeaderboard = true
if IsOnLeaderboard == true then
workspace.Leaderboard1.SurfaceGui.Holder:WaitForChild(plr.Name).Rap.Text = plr:WaitForChild("leaderstats"):WaitForChild("Rap").Value
print("da")
end
break
end
end
if Rap and IsOnLeaderboard == false then
local NewLBFrame = game.ReplicatedStorage:WaitForChild("LeaderBoardFrame"):Clone()
NewLBFrame.Name = plr.Name
NewLBFrame.Player.Text = Name
NewLBFrame.Rap.Text = Rap
NewLBFrame.Rank.Text = "#"..rank
NewLBFrame.Position = UDim2.new(0, 0, NewLBFrame.Position.Y.Scale + (0.08 * #game.Workspace.Leaderboard1.SurfaceGui.Holder:GetChildren()), 0)
NewLBFrame.Parent = game.Workspace.Leaderboard1.SurfaceGui.Holder
end
end
end)
end
while true do wait()
for _, frame in pairs(game.Workspace.Leaderboard1.SurfaceGui.Holder:GetChildren()) do
frame:Destroy()
end
Update()
print("Updated")
wait(10)
end
end)
Please Help