Selling  [PRO] Roblox Universal Game Manager - Lua Script (DataSave + Leaderboard + Admin)

Discussion in 'Roblox Services for Sale - Buy & Sell' started by luuc, 5/2/26.

  1. luuc

    luuc
    Expand Collapse
    High Risk Status: User has been flagged by the system for one or more reasons. Proceed with caution.

    0   0   0

    Offline
    Joined:
    5/2/26
    Posts:
    1
    Likes Received:
    0
    My Location:
    Price $:
    10
    Buy Now Link:
    Buy Now
    -- [[ UNIVERSAL GAME MANAGER ]]
    -- Features: Auto-Saving DataStore, Leaderboard, and Admin Commands
    -- Instructions: Place this in ServerScriptService

    local DataStoreService = game:GetService("DataStoreService")
    local PlayerData = DataStoreService:GetDataStore("GlobalPlayerData_V1")
    local Players = game:GetService("Players")

    -- SETTINGS
    local ADMIN_USER_IDS = {000000} -- Replace 000000 with your Roblox ID to use admin commands
    local STARTING_COINS = 100

    -- [[ LEADERBOARD & DATA LOADING ]]
    Players.PlayerAdded:Connect(function(player)
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats"
    leaderstats.Parent = player

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

    -- Load Data
    local success, savedData = pcall(function()
    return PlayerData:GetAsync(tostring(player.UserId))
    end)

    if success and savedData then
    coins.Value = savedData
    else
    coins.Value = STARTING_COINS
    end

    -- [[ ADMIN COMMANDS ]]
    player.Chatted:Connect(function(message)
    local isAdmin = false
    for _, id in pairs(ADMIN_USER_IDS) do
    if player.UserId == id then isAdmin = true break end
    end

    if isAdmin then
    local args = string.split(message, " ")

    -- Command: /give [amount]
    if args[1] == "/give" and args[2] then
    coins.Value = coins.Value + tonumber(args[2])
    print("Admin added " .. args[2] .. " coins to " .. player.Name)
    end

    -- Command: /reset
    if args[1] == "/reset" then
    coins.Value = 0
    end
    end
    end)
    end)

    -- [[ DATA SAVING ]]
    local function save(player)
    local success, err = pcall(function()
    PlayerData:SetAsync(tostring(player.UserId), player.leaderstats.Coins.Value)
    end)
    if not success then warn("Could not save data for " .. player.Name .. ": " .. err) end
    end

    Players.PlayerRemoving:Connect(save)

    game:BindToClose(function()
    for _, player in pairs(Players:GetPlayers()) do
    save(player)
    end
    end)
     
    • This user is inactive. Hasn't logged into their account in over 60 days.