Handler Script
local DataStore = game:GetService("DataStoreService")
local StatsDataStore = DataStore:GetOrderedDataStore("key go buur") --Make It Hard So Hacker Cant Guess It
local ResetTime = script.Parent.TimeUntilReset
local Time = script.Parent.Time.Value
Time = 5
while wait(1) do
Time = Time - 1
script.Parent.Parent.ResetTime.TextLabel.Text = "Resetting in " .. Time .. " seconds..."
if Time == 0 then Time = ResetTime.Value
for i, plr in pairs(game.Players:GetPlayers()) do
wait()
StatsDataStore:SetAsync(plr.UserId, plr.leaderstats:FindFirstChild(script.Parent.Parent.Stats.Value).Value)
end
for i, leaderboardRank in pairs(script.Parent:GetChildren()) do
if leaderboardRank.ClassName == "Frame" then
leaderboardRank:Destroy()
end
end
local success, errorMsg = pcall(function()
local data = StatsDataStore:GetSortedAsync(false, script.Parent.PlayerInLB.Value)
local StatsPage = data:GetCurrentPage()
for rankInLB, dataStored in ipairs(StatsPage) do
local name = game.Players:GetNameFromUserIdAsync(tonumber(dataStored.key))
local id = tonumber(dataStored.key)
local statsname = dataStored.value
wait(0.1)
local Gui = script.Top:Clone()
Gui.PlrName.Text = name
Gui.Rank.Text = "#" .. rankInLB
Gui.Amount.Text = statsname
Gui.Parent = script.Parent
if Gui.Rank.Text == "#1" then
Gui.Color.Value = Color3.fromRGB(255, 255, 0) --Top 1 Background Color
script.Parent.Parent.Parent.Parent.Top1.Configuration.userId.Value = id
script.Parent.Parent.Parent.Parent.Top1.Tags.Container.pName.Text = name
end
if Gui.Rank.Text == "#2" then
Gui.Color.Value = Color3.fromRGB(98, 98, 98) --Top 2 Background Color
script.Parent.Parent.Parent.Parent.Top2.Configuration.userId.Value = id
script.Parent.Parent.Parent.Parent.Top2.Tags.Container.pName.Text = name
end
if Gui.Rank.Text == "#3" then
Gui.Color.Value = Color3.fromRGB(255, 85, 0) --Top 3 Background Color
script.Parent.Parent.Parent.Parent.Top3.Configuration.userId.Value = id
script.Parent.Parent.Parent.Parent.Top3.Tags.Container.pName.Text = name
end
end
end)
end
end
LeaderStats Script
local DataStore = game:GetService("DataStoreService")
local StatsDataStore = DataStore:GetDataStore("Kvhyj76455242")
function onPlayerEntered(newPlayer)
local stats = Instance.new("Folder")
stats.Name = "leaderstats"
local thing = Instance.new("IntValue")
thing.Name = script.Parent.Part.BillboardGui.Stats.Value
thing.Value = StatsDataStore:GetAsync(newPlayer.UserId) or 0
thing.Parent = stats
stats.Parent = newPlayer
thing.Changed:Connect(function(v)
StatsDataStore:SetAsync(newPlayer.UserId,v)
end)
end
game.Players.ChildAdded:Connect(onPlayerEntered)
Detect change script
script.Parent.BackgroundColor3 = script.Parent.Parent.Color.Value
script.Parent.Parent.Color:GetPropertyChangedSignal("Value"):Connect(function()
script.Parent.BackgroundColor3 = script.Parent.Parent.Color.Value
end)
Any help please?