Datastore failed to save but no errors

image
omg js mindset. again same with const and console.log i keep adding

Tricky, the code however is garbadge, its unreadable AND unoptimized.
you arent even naming your variables properly… No wonder its unfixable

Try to rewrite the code in another way, (like using another service or system, this often helps with looking at a different angle to what the code is supposed to achieve)
if the other way doesnt work, just retry this method, but this time using proper variable names:

if you dont know how naming works

just use the name for what its doing!
like for example:

  • temporary
  • box1
  • itterator
  • service_useless
  • TMP (this means temporary)
    etc.

Edit: I also would recommend using spaces inbetween operators.
NOT THIS: 1+1=2
YES THIS: 1 + 1 = 2
its far more readable and most mistakes are incorrect useage of operators these days.

1+1=2 yes not ‎ ‎ ‎ ‎ ‎ 1‎ ‎ ‎ ‎ ‎ ‎ + ‎ ‎ ‎ ‎ ‎ 1 ‎ ‎ ‎ ‎ ‎ = ‎ ‎ ‎ ‎ ‎ 2 ‎ ‎ ‎ ‎ ‎ :pray::sob:

code that is bigger = bad just like in js .map/reduce/promise all good and for loop bad

and just like js
if(!smth)return;
so in lua
if(not smth) then return;end;

if not smth then
    return;
end;

^ multiple lines for no reason.

Found one issue when i pressed play and stop really quick…
so when player joins it sets the data to playing=true but since it takes abit to save that it doesnt have time to put statsLoaded for when the player leaves…

Fixed it in a way to also avoid data spam if anyone tries to spam join.

I just created this to fix the issue of when the player joins and then it takes like a second to save {isPlaying=true} to their datastore then after it’s done saving it checks if the player left and if so then it will put them on a temp ban from loading data for 1 or 2 mins, 2 cooldowns one server based and one on datastore.

Server one to avoid using GetAsync and then kicking when finding the cooldown inside data
image

And then the datastore cooldown if they try to do it on another server
image

image

so after all this will also avoid people who keep spamming join/leave causing datastore to be used up a lot and hitting rate limits…

Multiple Lines for better readabilty. Debugging with code yours is like finding a needle in a haystack.

If you don’t like your code being thousands of lines, then put reusable functions into modules.

its easier my way. code that isnt meant to be used by anyone else too and just me

Well don’t excpet people to be able to help you if they cant read your code. :sob:

1 Like

Nah it’s easy to read… don’t know what people seeing then

It’s easy to read for you, since YOU wrote it. We are outsiders who cant look at your entire codebase, so we expect to get the context from the code you give us, but your code is unreadable, context wise.

I mean that’s also the point lol because no one is meant to look at my code, my code is private work and a lot that shouldn’t be shared.

Then, again, don’t expect people to help you with code that is intentionally written to be unreadable by people from outside. Good Luck with your problem.

1 Like

Instead of just doing pcall(function() do: local succes, errorMessage = pcall(function() and then write the code under it. This gives you the error message (that you can print) and if it succeeded or not!

Note: if the pcall is supposed to return something, then errorMessage will be the date that it returned.

Example code:

-- Set data
local toSave = {"value_1", "value_2," "value_3"}

local success, errorMessage = pcall(function()
	return dataStore:SetAsync(plr.UserId, toSave)
end)

-- Get data
local success, data = pcall(function()
	return dataStore:GetAsync(plr.UserId)
end)
print(data) -- {"value_1", "value_2," "value_3"}

you clearly didn’t read the code I sent…, i on purposely do warn() to any failed pcall to try get it to log but it doesn’t log anything when i check the site.

Sorry, as already said in this post, the code is a bit hard to read.

ohh come on the pcalls are basically highlighted right there. because of the code block colouring

if you beg others for help then dont just say they are wrong for no good reason.
ALSO WHAT YOU SAY IS WRONG
ITS 1 + 1 = 2 NOT SO MUCH SPACE BRUH
and im only an outsider trying to help people on this forum

Multiple lines for no reason?
D O Y O U W A N T T O L O Z E Y O U R E Y E S ?
Your just insane if you want to be able to read that.
Its not readable, and unfixable in big stacks.

Have fun burning your eyes…

that’s not readable at all and not related to any of this.

and seems like you’re begging it because I don’t beg for help or anything I don’t even want help ever, my code is meant to be private and like some there and then cannot be leaked / due to law reasons etc.

my datastore issues are a real thing that most cannot be solved due to it being a error made by roblox