Используй этот код :
local DataStoreService = game:GetService('DataStoreService')
local VisibleData = DataStoreService:GetDataStore('VisibleTest')
local Players = game:GetService('Players')
local function PlayerAdd(player)
local key = 'Player_' .. player.UserId
local Data
local success, errorMessage = pcall(function()
Data = VisibleData:GetAsync(key)
end)
if not success then
warn("Ошибка при получении данных: " .. errorMessage)
return
end
if Data ~= nil then
player.PlayerGui.ScreenGui.test.Visible = Data
end
end
local function PlayerRemov(player)
local key = 'Player_' .. player.UserId
local Gui = player.PlayerGui.ScreenGui.test.Visible
local success, errorMessage = pcall(function()
VisibleData:SetAsync(key, Gui)
end)
if not success then
warn("Ошибка при сохранении данных: " .. errorMessage)
end
end
Players.PlayerAdded:Connect(PlayerAdd)
Players.PlayerRemoving:Connect(PlayerRemov)