#Data save bug

1 messages · Page 1 of 1 (latest)

molten hatch
#

and other part of script:-- Funkcja do zapisu
local function saveCharacters(plr)
local chars = {}
local folder = plr:FindFirstChild("characters")

if folder then
    for _, val in ipairs(folder:GetChildren()) do
        if val:IsA("BoolValue") and val.Value then
            table.insert(chars, val.Name)
        end
    end
end

local success, err
for i = 1, 3 do -- spróbuj do 3 razy
    success, err = pcall(function()
        charStore:SetAsync(plr.UserId, chars)
    end)
    if success then break end
    wait(2)
end

if not success then
    warn("Nie udało się zapisać postaci dla " .. plr.Name .. ": " .. tostring(err))
end

print("Zapisuję dla", plr.Name, " -> ", chars)

end
game.Players.PlayerAdded:Connect(function(plr)
print("Gracz: "..plr.Name.." UserId: "..plr.UserId)
end)

-- Gdy gracz dołącza
game.Players.PlayerAdded:Connect(function(plr)
-- leaderstats
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = plr

local Coins = Instance.new("IntValue")
Coins.Name = "Coins"
Coins.Value = 0
Coins.Parent = leaderstats

local Strikes = Instance.new("IntValue")
Strikes.Name = "Strikes"
Strikes.Value = 0
Strikes.Parent = leaderstats

-- Ładujemy postacie
loadCharacters(plr)

end)

-- Zapis przy wyjściu
game.Players.PlayerRemoving:Connect(function(plr)
saveCharacters(plr)
end)

game:BindToClose(function()
for _, plr in ipairs(game.Players:GetPlayers()) do
saveCharacters(plr)
end
end)

-- Obsługa eventu odblokowania postaci
event.OnServerEvent:Connect(function(plr, charName)
local characters = plr:FindFirstChild("characters")
if characters and not characters:FindFirstChild(charName) then
local val = Instance.new("BoolValue")
val.Name = charName
val.Value = true
val.Parent = characters
end
end)

earnest citrus
#

Stop using ai

#

Is the first step