Hi everyone, here is my script:
DataService = game:GetService("DataStoreService")
storage = game:GetService("ReplicatedStorage")
billboard = game.Workspace.ClanKillsBoard.Surface.GUI
function update()
local clans = storage.GlobalData.Clans:GetChildren()
for i, v in pairs(clans) do
local GlobalData = DataService:GetDataStore("GlobalData", "clans")
local increment = GlobalData:IncrementAsync(v.Name, v.Value)
print ("Incremented " .. v.Name .. " by " .. v.Value)
v.Value = 0
end
end
function clean()
for i, v in pairs(billboard.Frame:GetChildren()) do
if v:IsA("TextLabel") then
v:Destroy()
end
end
end
function create(name, i, kills)
local obj = Instance.new("TextLabel")
obj.Parent = billboard.Frame
obj.Text = (name .. " - " .. kills)
obj.Name = i
obj.BackgroundTransparency = 1
obj.BorderSizePixel = 0
end
while wait(10) do
update()
local OrderedData = DataService:GetOrderedDataStore("GlobalData", "clans")
pages = OrderedData:GetSortedAsync(false, 20)
page = pages:GetCurrentPage()
clean()
for rank, data in ipairs(page) do
create(data.key, rank, data.value)
end
for i, v in pairs(billboard.Frame:GetChildren()) do
if v.Name == "1" then
v.BackgroundTransparency = 0
v.BorderSizePixel = 2
v.BorderColor3 = Color3.new(236,195,100)
end
end
end
It is to incrementally update the global kills that each in game faction has and then retrieve the incremented data to a leaderboard.
I’ve been using the DataStore explorer plugin and see that the ordered datastore does work, however it’s not incrementing. If I search for the key alone (non-ordered) it will return the correct key and incremented value.
Where am I going wrong here?
Thanks