I don't know why this isn't working, it prints "SavedSkinEquiped", but then when I rejoin, the value is ""
game.Players.PlayerAdded:Connect(function(player)
local skinEquiped = Instance.new("StringValue")
skinEquiped.Name = "SkinEquiped"
skinEquiped.Parent = player
local player_data
pcall(function()
player_data = skinEquipedDataStores:GetAsync(player.UserId.."-SkinEquiped")
end)
if player_data ~= nil then
skinEquiped.Value = player_data
else
skinEquiped.Value = defaultSkinEquiped
end
local bindableEvent = Instance.new("BindableEvent")
game.Players.PlayerRemoving:Connect(function(player)
pcall(function()
skinEquipedDataStores:SetAsync(player.UserId.."-SkinEquiped", player.SkinEquiped.Value)
print("SavedSkinEquiped")
playersLeft = playersLeft -1
bindableEvent:Fire()
end)
end)
game:BindToClose(function()
while playersLeft > 0 do
bindableEvent.Event:Wait()
end
end)
end)
