Okay so I have this table:
local defaultdatas = {
Enchantments = 0
Slot1 = 0,
Enchantments1 = 0,
Slot2 = 0,
Enchantments2 = 0,
Slot3 = 0,
Enchantments3 = 0,
Slot4 = 0,
Enchantments4 = 0,
Slot5 = 0,
Enchantments5 = 0
}
Then this line of code
local DataStore = game:GetService("DataStoreService")
local HttpService = game:GetService("HttpService")
local ds = DataStore:GetDataStore("Playerdata")
game.Players.PlayerAdded:connect(function(player)
local datas = ds:GetAsync(player.UserId)
if datas then
datas = HttpService:JSONDecode(datas)
else
datas = defaultdatas
end
local data = Instance.new("Folder",player)
data.Name = "Data"
local numberofslots = 5
local slotcurrentlyat = 1
for i = 1, numberofslots do
local slot = Instance.new("StringValue", data)
slot.Name = "Slot"..slotcurrentlyat
slot.Value = data["Slot"..slotcurrentlyat] or defaultdatas["Slot"..slotcurrentlyat]
local enchantments = Instance.new("StringValue", data)
enchantments.Name = "Enchantments"..slotcurrentlyat
enchantments.Value = data["Enchantments"..slotcurrentlyat] or defaultdatas["Enchantments"..slotcurrentlyat]
slotcurrentlyat = slotcurrentlyat + 1
wait()
end
end)
Apparently the only issues are:
enchantments.Value = data["Enchantments"..slotcurrentlyat] or defaultdatas["Enchantments"..slotcurrentlyat]
and
slot.Value = data["Slot"..slotcurrentlyat] or defaultdatas["Slot"..slotcurrentlyat]
also this error
ServerScriptService.Data:19: bad argument #3 to 'Value' (string expected, got Object)
obv this isn't the whole script, but these are the only parts linked to the issue I have. Please help.

3 comments
ty for the answer but I misspelled data with datas in the part where I set the slot value
Yep I was looking through it again and I did see that after. In general try to stay away from using plural variable names.
Or limit the scope of variables by using do end blocks