This array/table triggers Roblox's 104 DataStore error for some odd reason

I am unsure how this is too large to store into Roblox’s DataStores - it’s trying to say I’m saving an instance for some reason. However, all I am storing are strings and numbers - am I not supposed to do that? I have looked at the different topics like this and they aren’t helping.

Here is the table I am saving because I want to sort the values by names instead of using table[x : num]:

	local dataTable = {
		["MaxHP"] = char.MaxHP.Value,
		["HP"]  = char.MaxHP.HP.Value,
		["Shield"] = char.MaxHP.Shield.Value,
		["CurrentCharacter"] = game.Players.LocalPlayer.PlayerGui.Preserve.Character.Value,
		["Mode"] = game.Players.LocalPlayer:WaitForChild("leaderstats").Mode.Value,
		["Stage"] = game.Players.LocalPlayer.PlayerGui.Preserve.Id.Value,
		["MaxHPOnSpawn"] = game.Players.LocalPlayer.PlayerGui.Preserve.MaxHPMode.Value
	}

Is this because Shield is a bool?
image

image

I also use the client to fetch data to save it whenever you touch a checkpoint:

local tableToSave = workspace.FetchedData.OnServerEvent:Wait()

Is the method for getting the table the issue?

2 Likes

I think your problem might be ["CurrentCharacter"].
What is the ...Preserve.Character.Value value?

1 Like

It’s… a string, as I mentioned in the original post. Things like “Alena”, “Frobble”, “Sku”, etc.

1 Like

Can I see code where you saved the data? (Like where you did SetAsync etc)

1 Like

Leaving the comments in because it’s true… LOL.

-- This for lazy people who just came to copy & paste, not to learn the code...

-- // Assigning variables //
local DataStoreService = game:GetService("DataStoreService")
local dataStore = DataStoreService:GetDataStore("ProgressDataStore") -- This can be changed to whatever you want

local function saveData(player) -- The functions that saves data
	player.PlayerGui:WaitForChild("FetchData"):FireClient(player)
	
	local tableToSave = workspace.FetchedData.OnServerEvent:Wait()
	
	

	local success, err = pcall(function()
		dataStore:SetAsync(player.UserId, tableToSave) -- Save the data with the player UserId, and the table we wanna save
	end)

	if success then -- If the data has been saved
		print("Data has been saved!")
	else -- Else if the save failed
		warn(err)
		print("Data hasn't been saved!")
			
	end
end

game.Players.PlayerAdded:Connect(function(player) -- When a player joins the game



	local data -- We will define the data here so we can use it later, this data is the table we saved
	local success, err = pcall(function()

		data = dataStore:GetAsync(player.UserId) -- Get the data from the datastore

	end)

	if success and data then -- If there were no errors and player loaded the data
		print(unpack(data))
		player:WaitForChild("leaderstats").Mode.Value = data["Mode"]
		player.PlayerGui:WaitForChild("DataLoadClient"):FireClient(player, data)

		

	else -- The player didn't load in the data, and probably is a new player
		print("The player has no data!") -- The default will be set to 0
	end

end)

game.ReplicatedStorage.CheckpointCredits.OnServerEvent:Connect(function(player)
	local success, err  = pcall(function()
		saveData(player) -- Save the data
	end)

	if success then
		print("Data has been saved")
	else
		warn(err)
		print("Data has not been saved!")
	end
end)

game.Players.PlayerRemoving:Connect(function(player) -- When a player leaves
	local success, err  = pcall(function()
		saveData(player) -- Save the data
	end)

	if success then
		print("Data has been saved")
	else
		print("Data has not been saved!")
	end
	
	--[[task.wait(1)
	
	workspace.PlayerDataPersist.PlayerData:FindFirstChild(player.Name):Destroy()
	workspace.PlayerDataPersist.leaderstats:FindFirstChild(player.Name):Destroy()]]
end)

game:BindToClose(function() -- When the server shuts down
	for _, player in pairs(game.Players:GetPlayers()) do -- Loop through all the players
		local success, err  = pcall(function()
			saveData(player) -- Save the data
		end)

		if success then
			print("Data has been saved")
		else
			print("Data has not been saved!")
		end
	end
end)

The server tells the client to give it the data and then it attempts to save it.

1 Like

Did you ever print tableToSave to ensure that everything is correctly transferred over?

1 Like

Thing is, it doesn’t save (I don’t think) because apparently I’m trying to save an Instance…

1 Like

print tableToSave before the pcall function so you can view the table and make sure its all sorted out. Send a screenshot if you can

1 Like

I have stated at least 3 times that the data doesn’t save.

All I can get for you is this:

--after running print(dataTable) from the client's end
                    ["CurrentCharacter"] = "Frobble",
                    ["HP"] = 6,
                    ["Lives"] = 10,
                    ["MaxHP"] = 6,
                    ["MaxHPOnSpawn"] = 6,
                    ["Mode"] = "Assist",
                    ["Shield"] = false,
                    ["Stage"] = 2

I also don’t think it’s a Studio issue as DataStores usually are the same between Studio and the game client as it loads my credits correctly either way.

Sorry for the misunderstanding, I meant print tableToSave from the saveData function (on the server). Check this value to ensure everything was passed over correctly to the server.

1 Like

There is no misunderstanding here…?

1 Like

It seems to be trying to save my Player instance instead of the table; is it possible to fix that? Do I have to do some funky argument 2 stuff?

1 Like

You are using the RemoteEvent incorrectly here, OnServerEvent will have the Player as the first Argument, when you yield until a event fires, it will give you the data that came from the event, which in this case, the Player, instead of any relevant data from your DataStore, as you havent given it any other data to get.

Also, please do not let the Client have a say in what is saved by the DataStore, especially with important data like this, Exploiters are able to Manipulate the Client and add whatever data they want to it.

1 Like

No, that’s not the issue. The issue is that I’m using local x = workspace.Event.OnServerEvent:Wait() which only returns the player, while local x,y = workspace.Event.OnServerEvent:Wait() returns both the player and the table. How am I using the RemoteEvent incorrectly if I have done something similar?

1 Like

I’m not adding an anti cheat, it is an obby.

1 Like

Woah, my own solution worked and I was told that I was using a RemoteEvent incorrectly!

I dont think you are understanding anything im saying.

The Client should not have a say in what is going to be saved in your DataStore, thats how Exploiters can alter their stats, its not safe.

1 Like

It’s an obby, I don’t care if they cheat. You can either play legitimately or not + what is the reason for cheating in a game like this?

Most I would do is store the day the player first joined and then kick them if they gain too many credits. Other than that, I don’t really care that much. There aren’t even fighting aspects either, so…

They could set their credits using the remoteevent in small amounts anyways so I could just monitor it depending on the max credits you should be able to gain at the last (30th) checkpoint.

1 Like

Securing your game would mean they actually have to try in the game, which can have players play the game more often, if they can get everything without playing the game, whats the point of playing the game? Exploiters just make your game not fun, making nobody want to play it

Correction, why wouldn’t they?

What is the reason for cheating in a competition?
Whats the reason for cheating in a Exam?
Whats the reason for cheating in Sports?


Nobody says this because they dont want the players to not have fun, they say this to make it fun, and to keep players, its very important, and should be disregarded because “its just an obby”.

1 Like

I don’t need to secure it if cheating isn’t an issue. Nobody cares if you’re flying around and giving yourself infinite lives because it doesn’t impact anyone else. It’s basically a singleplayer game where you can talk to other people.

1 Like