im trying to save decals in data store, but for some reason it doesnt save, nor load. There are no errors in the output.
saving:
local datastore = game:GetService("DataStoreService") local wrap = datastore:GetDataStore("wrap1") local wrapcolor = datastore:GetDataStore("wrapcolor1") local rims = datastore:GetDataStore("rims1") local roofscoop = datastore:GetDataStore("roofscoop1") local sides = datastore:GetDataStore("sides1") local spoiler = datastore:GetDataStore("spoiler1") local rcamber = datastore:GetDataStore("rcamber1") local roffset = datastore:GetDataStore("roffset1") local fcamber = datastore:GetDataStore("fcamber1") local foffset = datastore:GetDataStore("foffset1") local decalsave1 = datastore:GetDataStore("decalsave1") local decalsave12 = datastore:GetDataStore("decalsave12") script.Parent.OnServerEvent:Connect(function(player) local table = {} game.Lighting[player.Name.."Cars"].Car1:ClearAllChildren() local e = game.Lighting[player.Name.."Cars"].CurrentCarName[game.Lighting[player.Name.."Cars"].CurrentCarName.Value]:Clone() e.Parent = game.Lighting[player.Name.."Cars"].Car1 for i, v in pairs(e.Body:GetDescendants()) do if v:IsA("Decal") then table.insert(table, { ["Texture"] = obj.Texture; ["ParentName"] = obj.Parent.Name; }) print("saving") end end decalsave1:SetAsync("key", table) end)
loading:
local datastore = game:GetService("DataStoreService") local exhaust1 = datastore:GetDataStore("exhaust1") local fbumper1 = datastore:GetDataStore("fbumper1") local hood1 = datastore:GetDataStore("hood1") local rbumper1 = datastore:GetDataStore("rbumper1") local rims1 = datastore:GetDataStore("rims1") local roofscoop1 = datastore:GetDataStore("roofscoop1") local sides1 = datastore:GetDataStore("sides1") local spoiler1 = datastore:GetDataStore("spoiler1") local bodycolor1 = datastore:GetDataStore("bodycolor1") local interiorcolor11 = datastore:GetDataStore("interiorcolor11") local interiorcolor21 = datastore:GetDataStore("interiorcolor21") local rimcolor1 = datastore:GetDataStore("rimcolor1") local tonecolor1 = datastore:GetDataStore("tonecolor1") local windowtint1 = datastore:GetDataStore("windowtint1") local backleftbumper1 = datastore:GetDataStore("backleftbumper1") local backleftfender1 = datastore:GetDataStore("backleftfender1") local backrightbumper1 = datastore:GetDataStore("backrightbumper1") local backrightfender1 = datastore:GetDataStore("backrightfender1") local frontleftbumper1 = datastore:GetDataStore("frontleftbumper1") local frontleftfender1 = datastore:GetDataStore("frontleftfender1") local frontrightbumper1 = datastore:GetDataStore("frontrightbumper1") local frontrightfender1 = datastore:GetDataStore("frontrightfender1") local frontvisor1 = datastore:GetDataStore("frontvisor1") local decalhood1 = datastore:GetDataStore("decalhood1") local leftdoor1 = datastore:GetDataStore("leftdoor1") local rearvisor1 = datastore:GetDataStore("rearvisor1") local rightdoor1 = datastore:GetDataStore("rightdoor1") local top1 = datastore:GetDataStore("top1") local wrap1 = datastore:GetDataStore("wrap1") local wrapcolor1 = datastore:GetDataStore("wrapcolor1") local brakes1 = datastore:GetDataStore("brakes1") local grip1 = datastore:GetDataStore("grip1") local power1 = datastore:GetDataStore("power1") local transmission1 = datastore:GetDataStore("transmission1") local rcamber = datastore:GetDataStore("rcamber1") local roffset = datastore:GetDataStore("roffset1") local fcamber = datastore:GetDataStore("fcamber1") local foffset = datastore:GetDataStore("foffset1") local decalsave1 = datastore:GetDataStore("decalsave1") local decalsave12 = datastore:GetDataStore("decalsave12") local Car1 = datastore:GetDataStore("Car1") local player = script.Parent.player.Value wait(0.1) script.Parent.Parent:WaitForChild(player.Name.."Data").Slot1.Car.Value = Car1:GetAsync(player.UserId) or "Empty" local e = game.Lighting.Cars[script.Parent.Parent:WaitForChild(player.Name.."Data").Slot1.Car.Value]:Clone() local tab = decalsave1:GetAsync("key") or {} if tab then for i, v in pairs(tab) do local car= e local decal = Instance.new("Decal") decal.Parent = car.Body[obj.ParentName] print("loaded") end end e.Parent = game.Lighting[player.Name.."Cars"].Car1
thx ok
My guess based on what you've written here is that you are only calling one of the various DataStores that you've created with this line:
local tab = decalsave1:GetAsync("key") or {}
You've defined the DataStores, but you haven't set their information to be saved except for this one.
Other than that, it is generally better practice to place your models in the Server Storage or Replicated Storage instead of Lighting. Since a lot of these DataStores are just strings, I would also suggest possibly using one or two DataStores and using an Array instead (saves a table of values rather than a single value only) to save the ids.
You also only have one function, in the save script, so the loading script will not save anything, i would suggest placing the two scripts into a
game.Players.PlayerAdded:Connect(function(player end)
for the Load Script and
game.Players.PlayerRemoving:Connect(function(player end)
for the Save Script