So I wrote this script with the help of dev forum but the thing is the data saving the hat isn't working. I dont know why it isn't saving the hat that i put on.
local dss = game:GetService("DataStoreService")
local myDataStore = dss:GetDataStore("Outfit")
local function onPlayerLeave(plr)
local Wear = {}
for _,item in pairs(plr.Items) do
table.insert(Wear,item.Name)
end
pcall(function()
myDataStore:SetAsync(plr.UserId,Wear)
end)
end
local function onPlayerAdded(plr)
local data
local Folder = Instance.new("Folder",plr)
pcall(function()
data = myDataStore:GetAysnc(plr.UserId)
end)
for _,item in pairs(data) do
local Value = Instance.new("StringValue",Folder)
Value.Name = item
end
plr.CharacterAdded:Connect(function()
for i,accessory in pairs(Folder) do
game.ServerStorage.Everything[accessory.name]:Clone().Parent = plr.Character
end
end)
end

1 comment
oh alright