I've just recently learned how to data store values but I have no idea how to data store clothing. I have tried saving the players shirt but It doesn't seem like i'm doing in right.
local DataStore = game:GetService("DataStoreService")
local SaveData = DataStore:GetDataStore("CharSaves")
-- load savedata
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:wait()
local char = plr.Character
local ShirtID = char:FindFirstChild("Shirt").ShirtTemplate
local shirtdata
local success, failure = pcall (function()
shirtdata = SaveData:GetAsync(plr.UserId.."Shirt",ShirtID)
end)
if success ~= nil then
ShirtID = shirtdata
else
warn("Data Loading Error")
end
end)
--Save on removing
game.Players.PlayerRemoving:Connect(function(plr)
local char = plr.Character
local ShirtID = char:FindFirstChild("Shirt").ShirtTemplate
local success, failure = pcall (function()
SaveData:SetAsync(plr.UserId.."Shirt",ShirtID)
end)
if success then
print("Shirt Saved Successfully")
end
if failure then
warn("Shirt Save Error")
end
end)
