SO… Here I am, with a warning from my data store script:
local dss = game:GetService("DataStoreService")
local leaderstatsStore = dss:GetDataStore("LeaderstatsData1")
local boatsStore = dss:GetDataStore("BoatsData1")
local savedBoats = game.ServerStorage.SavedBoats
game.Players.PlayerAdded:Connect(function(plr)
local boat = nil
boat = boatsStore:GetAsync(plr.UserId)
if boat ~= nil then
boat.Parent = workspace.Boats
boat.Owner.Value = plr.Name -- making sure the boat's name is the player's name
boat.Name = plr.Name.."'s Boat"
else
--boat is nil, new player
--we will give them a starter boat
local starterBoat = savedBoats.Starter:Clone()
starterBoat.Parent = workspace.Boats
starterBoat.Owner.Value = plr.Name
starterBoat.Name = plr.Name.."'s Boat"
end
end)
game.Players.PlayerRemoving:Connect(function(plr)
for i, boat in pairs(workspace.Boats:GetChildren()) do
if boat.Owner.Value == plr.Name then
local success, errmess = pcall(function()
boatsStore:SetAsync(plr.UserId, boat)
end)
if success then
print("Data saved successfully")
else
warn(errmess)
end
end
end
end)
The warning comes here:
if success then
print("Data saved successfully")
else
warn(errmess) -- HERE!
end
Is this because I am testing in Studio? Or is it just that I CAN’T store Instances in a DataStore?