Yesterday night I was scripting and I didn’t have this error. Today I’m scripting and I receive an error in the title. It worked yesterday night but today it doesn’t save my values anymore.
local DS = game:GetService("DataStoreService")
local Inventory = DS:GetDataStore("FirstInventory")
game.Players.PlayerAdded:Connect(function(player)
local Folder = Instance.new("Folder")
Folder.Parent = player
Folder.Name = "Inventory"
local Folder = Instance.new("Folder")
Folder.Parent = player.Inventory
Folder.Name = "Seeds"
local Folder = Instance.new("Folder")
Folder.Parent = player.Inventory
Folder.Name = "Plants"
local Folder = Instance.new("Folder")
Folder.Parent = player.Inventory
Folder.Name = "Furniture"
local WheatSeed = Instance.new("IntValue")
WheatSeed.Name = "Wheat"
WheatSeed.Parent = player.Inventory.Seeds
local StrawberrySeed = Instance.new("IntValue")
StrawberrySeed.Name = "Strawberry"
StrawberrySeed.Parent = player.Inventory.Seeds
local CarrotSeed = Instance.new("IntValue")
CarrotSeed.Name = "Carrot"
CarrotSeed.Parent = player.Inventory.Seeds
local WatermelonSeed = Instance.new("IntValue")
WatermelonSeed.Name = "Watermelon"
WatermelonSeed.Parent = player.Inventory.Seeds
local PotatoSeed = Instance.new("IntValue")
PotatoSeed.Name = "Potato"
PotatoSeed.Parent = player.Inventory.Seeds
local CoconutSeed = Instance.new("IntValue")
CoconutSeed.Name = "Coconut"
CoconutSeed.Parent = player.Inventory.Seeds
local BananaSeed = Instance.new("IntValue")
BananaSeed.Name = "Banana"
BananaSeed.Parent = player.Inventory.Seeds
local PineappleSeed = Instance.new("IntValue")
PineappleSeed.Name = "Pineapple"
PineappleSeed.Parent = player.Inventory.Seeds
local CabbageSeed = Instance.new("IntValue")
CabbageSeed.Name = "Cabbage"
CabbageSeed.Parent = player.Inventory.Seeds
local TomatoSeed = Instance.new("IntValue")
TomatoSeed.Name = "Tomato"
TomatoSeed.Parent = player.Inventory.Seeds
local WheatPlant = Instance.new("IntValue")
WheatPlant.Name = "WheatPlant"
WheatPlant.Parent = player.Inventory.Plants
local CarrotPlant = Instance.new("IntValue")
CarrotPlant.Name = "CarrotPlant"
CarrotPlant.Parent = player.Inventory.Plants
local PotatoPlant = Instance.new("IntValue")
PotatoPlant.Name = "PotatoPlant"
PotatoPlant.Parent = player.Inventory.Plants
local CabbagePlant = Instance.new("IntValue")
CabbagePlant.Name = "CabbagePlant"
CabbagePlant.Parent = player.Inventory.Plants
local TomatoPlant = Instance.new("IntValue")
TomatoPlant.Name = "TomatoPlant"
TomatoPlant.Parent = player.Inventory.Plants
local Cash = Instance.new("IntValue")
Cash.Name = "Cash"
Cash.Parent = player
local Soil = Instance.new("IntValue")
Soil.Name = "Soil"
Soil.Parent = player.Inventory.Furniture
local Hay = Instance.new("IntValue")
Hay.Name = "Haybale"
Hay.Parent = player.Inventory.Furniture
local SmlDk = Instance.new("IntValue")
SmlDk.Name = "SmallDeck"
SmlDk.Parent = player.Inventory.Furniture
local LgDk = Instance.new("IntValue")
LgDk.Name = "LargeDeck"
LgDk.Parent = player.Inventory.Furniture
local DkSr = Instance.new("IntValue")
DkSr.Name = "DeckStairs"
DkSr.Parent = player.Inventory.Furniture
local LogSeat = Instance.new("IntValue")
LogSeat.Name = "LogSeat"
LogSeat.Parent = player.Inventory.Furniture
local CmpFre = Instance.new("IntValue")
CmpFre.Name = "Campfire"
CmpFre.Parent = player.Inventory.Furniture
local Flag = Instance.new("IntValue")
Flag.Name = "Flag"
Flag.Parent = player.Inventory.Furniture
local Wall = Instance.new("IntValue")
Wall.Name = "Wall"
Wall.Parent = player.Inventory.Furniture
local GrnScrn = Instance.new("IntValue")
GrnScrn.Name = "GreenScreen"
GrnScrn.Parent = player.Inventory.Furniture
local Chair = Instance.new("IntValue")
Chair.Name = "Chair"
Chair.Parent = player.Inventory.Furniture
local Table = Instance.new("IntValue")
Table.Name = "Table"
Table.Parent = player.Inventory.Furniture
local Bed = Instance.new("IntValue")
Bed.Name = "Bed"
Bed.Parent = player.Inventory.Furniture
local playerUserId = "Player_"..player.UserId
local success, errormessage = pcall(function()
Data = Inventory:GetAsync(playerUserId)
end)
if success then
WheatSeed.Value = Data.Wheat
StrawberrySeed.Value = Data.Strawberry
CarrotSeed.Value = Data.Carrot
WatermelonSeed.Value = Data.Watermelon
PotatoSeed.Value = Data.Potato
CoconutSeed.Value = Data.Coconut
BananaSeed.Value = Data.Banana
PineappleSeed.Value = Data.Pineapple
CabbageSeed.Value = Data.Cabbage
TomatoSeed.Value = Data.Tomato
WheatPlant.Value = Data.WheatPlant
CarrotPlant.Value = Data.CarrotPlant
PotatoPlant.Value = Data.PotatoPlant
CabbagePlant.Value = Data.CabbagePlant
TomatoPlant.Value = Data.TomatoPlant
Cash.Value = Data.Cash
Soil.Value = Data.Soil
Hay.Value = Data.Hay
SmlDk.Value = Data.SmallDeck
LgDk.Value = Data.LargeDeck
DkSr.Value = Data.DeckStairs
LogSeat.Value = Data.LogSeat
CmpFre.Value = Data.LogSeat
Flag.Value = Data.Flag
Wall.Value = Data.Wall
GrnScrn.Value = Data.GreenScreen
Chair.Value = Data.Chair
Table.Value = Data.Table
Bed.Value = Data.Bed
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "Player_"..player.UserId
local Data = {
Wheat = player.Inventory.Seeds.Wheat.Value,
Strawberry = player.Inventory.Seeds.Strawberry.Value,
Carrot = player.Inventory.Seeds.Carrot.Value,
Watermelon = player.Inventory.Seeds.Watermelon.Value,
Potato = player.Inventory.Seeds.Potato.Value,
Coconut = player.Inventory.Seeds.Coconut.Value,
Banana = player.Inventory.Seeds.Banana.Value,
Pineapple = player.Inventory.Seeds.Pineapple.Value,
Cabbage = player.Inventory.Seeds.Cabbage.Value,
Tomato = player.Inventory.Seeds.Tomato.Value,
WheatPlant = player.Inventory.Plants.WheatPlant.Value,
CarrotPlant = player.Inventory.Plants.CarrotPlant.Value,
PotatoPlant = player.Inventory.Plants.PotatoPlant.Value,
CabbagePlant = player.Inventory.Plants.CabbagePlant.Value,
TomatoPlant = player.Inventory.Plants.TomatoPlant.Value,
Cash = player.Cash.Value,
Soil = player.Inventory.Furniture.Soil,
Hay = player.Inventory.Furniture.Haybale,
SmallDeck = player.Inventory.Furniture.SmallDeck,
LargeDeck = player.Inventory.Furniture.LargeDeck,
DeckStairs = player.Inventory.Furniture.DeckStairs,
LogSeat = player.Inventory.Furniture.LogSeat,
CampFire = player.Inventory.Furniture.Campfire,
Flag = player.Inventory.Furniture.Flag,
Wall = player.Inventory.Furniture.Wall,
GreenScreen = player.Inventory.Furniture.GreenScreen,
Chair = player.Inventory.Furniture.Chair,
Table = player.Inventory.Furniture.Table,
Bed = player.Inventory.Furniture.Bed
}
local success, errormessage = pcall(function()
Inventory:SetAsync(playerUserId, Data)
end)
if success then
print("Data Saved Success")
else
print("Data Saved Unsuccessful")
warn(errormessage)
end
end)