local Players = game.Players
local DataStoreService = game:GetService("DataStoreService")
local Info1 = DataStoreService:GetDataStore("Info1")
local function savePlayerData(plr)
local success, error = pcall(function()
local PlayerGui = plr.PlayerGui
for _, button in pairs(plr.PlayerGui:WaitForChild("Game").Profit.Markets:GetChildren()) do
if button:IsA("TextButton") then
for _, frame in pairs(button:GetChildren()) do
if frame:IsA("Frame") then
local boughtLevels = frame:WaitForChild("boughtLevels")
local BuyLvlPrice = frame:WaitForChild("BuyLvlPrice")
local GiveMoneyReal = frame:WaitForChild("GiveMoneyReal")
local GiveMoneyInHour = frame:WaitForChild("GiveMoneyInHour")
Info1:SetAsync(plr.UserId, {boughtLevels.Value,BuyLvlPrice.Value,GiveMoneyReal.Value,GiveMoneyInHour.Value})
print("Saved")
end
end
end
end
end)
if not success then
warn("Error loading player data: " .. error)
end
end
local function loadPlayerData(plr)
local success, error = pcall(function()
local PlayerGui = plr.PlayerGui
for _, button in pairs(PlayerGui:WaitForChild("Game").Profit.Markets:GetChildren()) do
if button:IsA("TextButton") then
for _, frame in pairs(button:GetChildren()) do
if frame:IsA("Frame") then
local currencyData = Info1:GetAsync(plr.UserId)
local boughtLevels = frame:WaitForChild("boughtLevels").Value
local BuyLvlPrice = frame:WaitForChild("BuyLvlPrice").Value
local GiveMoneyReal = frame:WaitForChild("GiveMoneyReal").Value
local GiveMoneyInHour = frame:WaitForChild("GiveMoneyInHour").Value
if currencyData then
local boughtLevels = currencyData[1]
local BuyLvlPrice = currencyData[2]
local GiveMoneyReal = currencyData[3]
local GiveMoneyInHour = currencyData[4]
print("Loaded")
else
print("Data not found for player")
end
end
end
end
end
end)
if not success then
warn("Error loading player data: " .. error)
end
end
Players.PlayerAdded:Connect(function(plr)
loadPlayerData(plr)
end)
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr,event)
if event == "A" then
savePlayerData(plr)
else
loadPlayerData(plr)
end
end)
All printing, but info dont saving or loading. No errors in output