hello! so i basically tried to make a datastore code, i used one that already worked, but when it SetAsync, it always say that datastore does not allow strings, which is false as a plugin that allow people to edit their datastore allow you to define a string, any help?
Please carefully read the rules about the dev forum before posting. It CLEARLY states to post code and state what attempts you made to solve it. If you cannot abide by the rules this post is probably going to get removed by some higher ups. That being said, I will gladly help if you post the code and the erros associated with it.
Data.lua.rbxl (191.5 KB) here is the code, the error is 22:12:24.970 - 103: string is not allowed in data stores. please DO NOT USE THE CODE
like I said before PLEASE read the rules. It says to use the correct formatting such as print("hi")
. Secondly, no big developer would steal a datastore script that doesnt work properly. Most, if not all, roblox developers use custom modules or data saving methods. If you cant post corrrectly this next time I cant help you.
local DataStoreService = game:GetService("DataStoreService")
local GameData = DataStoreService:GetOrderedDataStore("TestThingEpicInv")
game.Players.PlayerAdded:Connect(function(player)
local dat = Instance.new("Folder")
dat.Name = "dat"
dat.Parent = player
local ItemNBR = Instance.new("IntValue")
ItemNBR.Name = "ItemNBR"
ItemNBR.Parent = dat
ItemNBR = 0
local StringedTable = Instance.new("StringValue")
StringedTable.Name = "STTB"
StringedTable.Parent = dat
StringedTable.Value = ",~"
local data
local success, errormessage = pcall(function()
data = GameData:GetAsync(player.UserId.."-ItemNBR")
data2 = GameData:GetAsync(player.UserId.."-STTB")
end)
if data2 ~= nil then
-- ItemNBR.Value = data
print(data2)
player.dat.STTB.Value = data2..",~"
else
if data == nil then
-- ItemNBR.Value = 0
player.dat.STTB.Value = ",~"
end
print("DataLoadError")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall (function()
GameData:SetAsync(player.UserId.."-ItemNBR",player.dat.ItemNBR.Value)
GameData:SetAsync(player.UserId.."-STTB", tostring(player.dat.STTB.Value))
end)
if success then
print("Saved")
else
print("ErrorSave")
warn(errormessage)
end
end)
so at first glance, i notice you are saving two datastores at the same time which is NEVER a good idea unless you are A very good developer that knows datastores well because if you have say 20 people joining thats 40 datastores at once which will cause the requests to be dropped. Secondly, the main issue I see is that you, as the error states, are storing a string value which is not allowed. What I do and what I recommend is storing all the values in the game in a single table and then sending that in a single datastore request. Then, when you recieve it you can simply call the key of the table reducing code and complexity.
Alright thank you very much for your help
no problem just be sure to read the post rules next time