#Global Leaderboard.

1 messages · Page 1 of 1 (latest)

rigid prawn
#

can someone explain to me why my code is not working correctly, it should get data from ordered data store but all "points" are 0. (There are over 4k entries with most of them having more than 0 points ofcourse)

compact parcel
#

hm

#

try adding a function

rigid prawn
#

wym?.

languid pewterBOT
#

studio** You are now Level 1! **studio

rigid prawn
#

you dont see the functions?

jade path
#

a

spark path
#

WOWIE ZOWIE THATS A FUCK TON OF CODE

#

nice

rigid prawn
#

thanks but its not working properly its been 6 hours now of bug fixing xd

#

i am very burnt out the problem could be in my face and i still dont see it xd

spark path
#

wait what userservice be

jade path
#

I never done anything with global shit so ama head out

little solar
#

if the data in the stores are 0 then it's a problem with saving data

rigid prawn
#

well the data is not 0 xd

little solar
#

i'd wager this is happening because you're changing values on the client when this should be done on the server

spark path
#

@little solar good logic indeed

languid pewterBOT
#

studio** You are now Level 11! **studio

spark path
#

hmmm

little solar
#

very common beginner mistake

rigid prawn
#

changing values on the client?

#

please explain

spark path
#

yeah that makes sense, i should really learn dss tho

#

@rigid prawn it needs to be on server

#

the client is the player

rigid prawn
#

everything is on server

spark path
#

even saving?

rigid prawn
#

ofcourse

#

i have a seperate data store script for that

#

in server script service

spark path
#

what about changing the values

#

before saving them

rigid prawn
#

also done through server script

#

Since i can see the values of data in the actual data store in roblox there shouldn't be a client mistake

little solar
#

you said they're all 0

rigid prawn
#

hold on

#

thats my id

#

for example

#

and it stores in the playerpoints 26 points

spark path
#

so its a reading problem

rigid prawn
#

most likely

#

but where is the reading problem thats what i dont see xd

spark path
#

maybe you're printing to much

#

the getuserids from userservice

#

doesnt print in order

#

how many entries

#

are in the leaderboard

#

oh 4k

rigid prawn
#

this is the output when i run the game

#

since i my self have 26 points and many other players got more than 0 they should be here

spark path
#

so is it saving properly

#

oh wait no

rigid prawn
#

it is since you can see the data on the actual data store page

languid pewterBOT
#

studio** You are now Level 2! **studio

spark path
#

so its a reading problem definitely

#

do you want to get your own stats

#

isnt yours the only one that isnt 0

rigid prawn
#

i just want the top stats thats why i use ordered data store

spark path
#

ooo

little solar
#

show save side

spark path
little solar
spark path
rigid prawn
#

wait discord aint letting me xd

#

can you read that or is it too small?

#

cause for some reason i cant post the whole script

#

and adding points gets done by another script which uses increment

spark path
#

are you the only one with points above 0

rigid prawn
#

no

#

many people are for sure

spark path
#

o

rigid prawn
#

above 400 people

#

actually 439 to be exact

#

@little solar tell me you got something ;')

little solar
# rigid prawn

this is absolutely horrendous use of datastores, i'm surprised it's working at all without error

rigid prawn
#

HAHAHAHAHA

little solar
#

but yea you're storing 0's

spark path
#

but its saving tho

#

im pretty sure he showed his stats

rigid prawn
spark path
#

it has to be a reading problem

little solar
little solar
rigid prawn
#

but you can see at the data store page there are the values

little solar
#

well to be more specific, it's saving whatever the last value was, or 0, which is always going to be 0 unless they've already got an entry

rigid prawn
#

and the increment works correctly adding points whenever a win occurs

little solar
#

i.e from its current state it will never save new data

spark path
#

it so confuse me

rigid prawn
#

yeah i am totally burnt here

#

how do i even fix that?

#

also how could i make the data stores not horrendous xd

spark path
#

you might just have to redo it or smtn

#

i dont really know dss that well

little solar
rigid prawn
#

huh

#

what does that even mean how is it not my data?

#

we can join a call if that helps

little solar
#

yeah it's not your data

rigid prawn
#

why is it not my data?

#

if it is my data that i am looking at

little solar
#

as in, yes it's your data with your userid that's all fine, but that's not the data your code is using

rigid prawn
#

what xD

#

first the data store was not an ordered data store if thats why this is happening

little solar
#

yep 100% you're looking at the wrong thing

#

i haven't used the new datastore manager so i just checked a few things and i confirm ordered stores do not show in the datastore manager

rigid prawn
little solar
rigid prawn
#

thats all the data store my game uses

little solar
#

you're looking at the normal store (which your code no longer uses) and seeing old data in it, then wondering why it's all 0's

#

and then to top it off

little solar
#

as text

rigid prawn
#

-- Function to save player data
function savePlayerData(player)
local success, errorMessage = pcall(function()
local userId = tostring(player.UserId)

    local success, errorMessage = pcall(function()
        local currentPoints = PointsDataStore:GetAsync(userId) or 0 -- Ensure we get the latest stored points
        PointsDataStore:SetAsync(userId, currentPoints) -- Save the existing points without overwriting them
    end)
    
    StreaksDataStore:SetAsync(player.UserId, player:GetAttribute("Streak") or 0)
    CurrencyDataStore:SetAsync(player.UserId, player:GetAttribute("Currency") or 0)
    XPDataStore:SetAsync(player.UserId, player:GetAttribute("XP") or 0)
    BPXPDataStore:SetAsync(player.UserId, player:GetAttribute("BPXP") or 0)
end)

if success then
    print(player.Name .. "'s data has been saved successfully.")
else
    warn("Failed to save data for " .. player.Name .. ": " .. errorMessage)
end

end

little solar
#
        local success, errorMessage = pcall(function()
            local currentPoints = PointsDataStore:GetAsync(userId) or 0 -- Ensure we get the latest stored points
            PointsDataStore:SetAsync(userId, currentPoints) -- Save the existing points without overwriting them
        end)```
this is the only place i see a PointsDataStore:SetAsync, and you're using getasync (completely ignoring the attribute you use later), which is guaranteed to be 0 (because of the `or 0`) on first load, and since it never takes new data into it, it is guaranteed to always be 0.
#

only exception is if they already had data.. in the ordered store, which you wouldn't have had because you changed to a new, completely empty store when you switched from getdatastore to getorderedstore

rigid prawn
#

i am understanding so far

#

but how do i fix all that mess without losing any data

little solar
#

and now you're confused because you have the old datastore in the dashboard store manager with the same name

rigid prawn
#

exactly

#

i messed up big time its my first time getting that deep xd

little solar
#

(my first theory being correct)

rigid prawn
#

thats actually true

languid pewterBOT
#

studio** You are now Level 3! **studio

rigid prawn
#

you are very good at this

#

so what do i do now?

little solar
#

i've had a lot of practice fingerguns

#

fix your shit code

rigid prawn
#

😦

little solar
#

all the stuff that doesn't need to go in an ordered store, put it in one regular store as a table

rigid prawn
#

yeah before disabling the leaderboard first day of release i had 50k errors for data requests xd

little solar
#

like {money=2, xp=100, etc} and only the stuff that needs to be ordered are on their own

rigid prawn
#

is there a way to transfer all data too or i have to reset everything to 0?

#

its been like 5 days from release

little solar
little solar
# rigid prawn is there a way to transfer all data too or i have to reset everything to 0?

as for this, so in the industry this is usually called migration. it happens when you change datastore methods and design patterns, such as changing how your savedata is structured or moving stores. i don't recommend performing datastore-wide operations since that'll take forever, instead just add a migration function to your loading method that detects if the data is based on an older version, and if so, migrate it to the newer version.

#

usually this is done by adding a .version=001 etc and incrementing it manually, writing in if not version or version < 1 then ... version=1 end ... if version < 2 then ... version=2 end important to note that you need to keep these sequential, as in, the migration needs to take every step, because you may have players joining still on the first version, or any version in between.

#

sometimes you can collate all the changes into one step but it's unlikely. running each migration step is often the way to go

#

as an alternative to using a .version value, you can also go by the date. i don't fully recommend that since it's a bit harder to control, but the option is there

rigid prawn
#

so lets say i have 5 data stores now and make them all 1 what happens to the 5 datastores? Do i delete them somehow?

little solar
#

and if you're wondering why shutting all servers down and running the migration while the game is set to private is not practical, the rate limits are too low, you'll be waiting for hours if not days for it to finish, even at 'only' 4000 players.

rigid prawn
#

So is it easier to just reset everything?

little solar
rigid prawn
#

so they dont take much space ig yeah

#

is there any chance we can get in a call and help me with all that?

little solar
#

and in case it hasn't properly hit you yet just how deep of a hole you've managed to get yourself into, here are the rate limits.

Each queue has a limit of 30 requests. When the limit of a queue is reached, requests fail with an error code in the 301-306 range, indicating that the requests have been dropped entirely.

Get GetAsync() 60 + numPlayers × 10

Set (limit is shared among all listed functions) SetAsync()
IncrementAsync()
UpdateAsync()
RemoveAsync() 60 + numPlayers × 10

just be thankful you have less than 10 stores in your code (including the new single-store with table data you're going to be using). barely.

Error codes you might come across and limits you might hit when using data stores to store data.

little solar
rigid prawn
#

understandable

#

how much would you charge tho?

little solar
#

happy to help you figure out where it's all going wrong and give you an outline of where to take it from there, but i'm not going to do everything for you fingerguns

little solar
rigid prawn
#

Alright man thanks a lot for helping out

#

Wish you the best!

spark path
#

oh we won

little solar
spark path
#

nah i just came back after learning dss

rigid prawn
#

if i actually manage to fix that i will invite yall to see my game xd

rigid prawn
#

@little solar I have made some progress and i think my script should work but it doesn't can you help me out a little bit?

little solar
rigid prawn
#

Well its on the same script but alright ig i can make a new thread xd

compact parcel
#

give me admin