DataStore error

So I have a datastore script that was going well till this happened.

I’m not a expert on this type of stuff, along with that the table I have has like 4000 lines since I wanted to have data for all stuff, I slimmed it down on the bottom post to give a example.

Script in game.Workspace

local DataStore2 = require(game.Workspace.MainModule) -- This is the Module we need I will post it in Description

local Settings = require(game.ReplicatedStorage.ModuleScript) -- You have to use a require(themodulescript/settingsucreated)

game.Players.PlayerAdded:Connect(function(plr) -- Plr added
	
	for i,v in pairs(Settings) do
		local datastore = DataStore2(i,plr) --i = the datastorename , plr = the player
		local where = v.Where --Where the datastore gets saved at
		if v.Where ~= "Player" then
			if plr:findFirstChild(v.Where) then--if the folder is already created then
				where = plr[v.Where]
			else
				local folder = Instance.new("Folder",plr) -- creates folder inside player
				folder.Name = v.Where -- sets the folder name
				
				where=folder -- this was the mistake
				
			end
		end
		
		if v.Where == "Player" then
			where= plr
		end
		--// Creates the Value
		local val = Instance.new(v.What,where)
		val.Name = i -- // The name u did put on left side inside the Module
		val.Value = v.Value --// How much if set
		
		--// Loading
		if datastore:Get() ~= nil then -- If datastore already exists
			val.Value = datastore:Get() -- loads in plrs data
		end
		
		--//Saving
		val.Changed:connect(function() -- if Value changes 
			datastore:Set(val.Value) -- Sets Datastore value to changed Value
		end)
		
	end
	
end)


--It wont save since we are in studio but to make it save in studio we just create a boolvalue inside ServerStorage , make it true

Table

-- To make it public visible on right put "Where" to "leaderstats"

local Settings = {
	["ExampleValue"] = {
		["Where"] = "leaderstats", -- Player means it gonna save inside player. This will be shown in the main script , this is just our settings, If you put something else it will create a folder inside the plr.
		["What"] = "IntValue",
		["Value"]= 500,
	},
	["ExampleValue2"] = {
		["Where"] = "leaderstats",
		["What"] = "IntValue",
		["Value"]= 0,
	},
	["ExampleValue3"] = {
		["Where"] = "leaderstats",
		["What"] = "IntValue",
		["Value"]= 0,
	}
}

return Settings

You are are using a for loop for individual settings, so you are sending a request for every single setting, you want to send a single datastore request with all the settings instead.

For example if i have a list like (car, dog, house, rat, plant, turtle)

Your doing it like this

client: cat

server: got it!

client: dog

server: got it!

client: house

server: okay too many requests!

Your supposed to do it like this

client: ({car,dog,house,rat,plant,turtle})

server: got it!

Ah, what do I have to edit on the script so it works with all of the stuff listed onto the table and not just separate checks?

Ok so I updated to DataStore2, it works a bit better but still same issue. I have no clue on how to fix this.
logs

Still having these issues with no fix solved. The Documentaion isn’t helpful and confusing, ugh. Nothing but a pure headache just to get a script to work.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.