local rs = game:GetService("ReplicatedStorage")
local DateStoreService = game:GetService("DataStoreService")
local GojoEquippedSkinDataBase = DateStoreService:GetDataStore("GojoEquippedSkinDataBase")
game.Players.PlayerAdded:Connect(function(player)
local HerosEquipped = Instance.new("Folder")
HerosEquipped.Name = "HerosEquipped"
local GojoSkinEquipped = Instance.new("StringValue")
GojoSkinEquipped.Name = "GojoSkinEquipped"
GojoSkinEquipped.Parent = HerosEquipped
HerosEquipped.Parent = player
local data ---- loads ticket data
local success1, errormessage1 = pcall(function()
data = GojoEquippedSkinDataBase:GetAsync(player.UserId.."-GojoSkinEquipped")
end)
if success1 then
print("success")
player.HerosEquipped.GojoSkinEquipped.Value = data
else
print("there was a error")
warn(errormessage1)
end
if not data then
player.HerosEquipped.GojoSkinEquipped.Value = "DefaultSkin"
end
end)
game.Players.PlayerRemoving:Connect(function(player)
if player.Currency.Tickets.Value then
local success = nil
local errormsg = nil
local attempt = 1
repeat
local success, errormessage = pcall(function()
GojoEquippedSkinDataBase:SetAsync(player.UserId.."-GojoSkinEquipped",player.HerosEquipped.GojoSkinEquipped.Value)
end)
attempt += 1
if not success then
warn(errormsg)
task.wait(3)
print("past")
end
if success then
else
warn("unable to save for",player.Name)
end
until success or attempt == 5
end
end)