Datastores screwing me over (No error message?)

Alright I’ve had this problem for a while and it has been getting on my nerves forever:

Here’s a code snippet:

        local saveattempts;
		saveattempts += 1;
		local success, err = pcall(function()
			return TycoonStore:SetAsync(player.UserId, savedData);
		if not success then error(err); end;
	until success or saveattempts >= 7;

Every time WITHOUT FAIL, this loop will print A but won’t print B. Best part? No error message. No hints to what’s going on. What the hell roblox?

In case anyone is wondering, savedData is a dictionary wrapped inside an array wrapped inside another array. For example, when I print out the data I’m trying to save, this is what prints in the output:

                    [1] =  {
                       ["boughtButtons"] =  {
                          [1] = "Buy Colorizer ",
                          [2] = "Buy Materializer "
                       ["presentButtons"] =  {
                          [1] = "CustomButtonTextStyle1",
                          [2] = "Style2",
                          [3] = "Style3",
                          [4] = "Test Button "

The script will literally stop running after reaching the SetAsync line. Why am I getting no error or no type of message. It doesn’t even give the generic “Module failed to load” vague message…

Anyone else know what’s going on? Anyone else have this problem?

I have absolutely know idea what’s causing this, but I would maybe try subbing out savedData for some placeholder data to see if it’s the issue.

Try remove the return before TycoonStore:SetAsync.

1 Like

Just like @Sekuriyo said, remove the return at return TycoonStore:SetAsync(player.UserId, savedData);

The return stops the rest of the code because you are returning something.

On a sidenote: I think you are pushing your Datastore to its limits due to that repeat loop.

Just remove it.

what if the saving fails? Also, I made sure after 7 attempts at saving, it would break out of the loop

Sometimes I data stores don’t work in studio but do work in the actual game.

Datastores are a lot of what if’s, there’s some good modules to cover all these edge cases, like ProfileService or Datastore2.