so i have a custom character creation and i would like to save the shirt template and pants template but it doesn’t save.
i never used datastore before so i don’t know what to do.
my script:
local DataStoreService = game:GetService("DataStoreService")
local Players = game:GetService("Players")
local ClothingSave = DataStoreService:GetDataStore("ClothingSave")
function Save(Chr, Plr)
local information = {
["Shirt"] = Chr.Shirt.ShirtTemplate;
["Pants"] = Chr.Pants.PantsTemplate;
}
DataStoreService:SetAsync(Plr.UserId, information)
end
function Load(Chr, Plr)
local good, info = pcall(function()
return(DataStoreService:GetAsync(Plr.UserId))
end)
print(Plr.Name, "DataStoreRetrivalInformation", good, info)
Chr.Shirt.ShirtTemplate = info.Shirt
Chr.Pants.PantsTemplate = info.Pants
end
If you’re trying to save from studio, you need to make sure the “Enable Studio Access to API Services” toggle is enabled in the game settings (the game must be published first).
What does the code for the PlayerAdded/PlayerRemoving look like? It’s possible PlayerRemoving isn’t getting a chance to fire if you’re the only one in game, so you may need to use game:BindToClose() as well as PlayerRemoving.