local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local DataStore = game:GetService("DataStoreService"):GetDataStore("Test")

local Data = {} -- For the player's data (ex. Data[player] or Data[plr], and then another ex. for specifying: Data[player]["Skins"])

local GroupId

local chads = {
    -- list of UserIds for special people.
}

-- SKIN FUNCTIONS
local function AddSkin()
end

local function DeleteSkin()
end

-- MELEE FUNCTIONS
local function AddMelee()
end

local function DeleteMelee()
end

-- MISC. FUNCTIONS
local function AddBucks()
end

local function AddXP()
end

-- EVENT FUNCTIONS
Events.LoadCharacter.OnServerEvent:Connect(function(player)
    local gotchildren = false

    if player then
        player:GetDescendants()
        gotchildren = true
    else
        warn("Cannot find parented children to the player. Unexpected error")
        return
    end

    if gotchildren then
        player:LoadCharacter()
    else
        warn("Cannot properly load player(s). Unepected error.")
        return
    end
end

Events.EquipSkin.OnServerEvent:Connect(function(player, skin)
    if CheckSkin(player, skin) then
        Data[player]["Skin"] = skin
        skin.Parent = workspace
        if skin.Parent == workspace then
            local skides = skin:GetDescendants():Clone()
            player.Character:GetDescendants():Destroy()
            skides.Parent = player.Character
            Events.LoadCharacter:FireServer()
        else
            warn("Skin error lolz")
            return
        end
    else
        return
    end
end

-- Initialization
Players.PlayerAdded:Connect(function(player)
    local key = "user_" .. player.UserId

    if DataStore:GetAsync(key) == nil then -- New player
        Data[player] = {
            ["Bucks"] = 0,                      -- How rich is da bois? We'll see lol
            ["XP"] = 0,                         -- Player's XP, used to determine what levels a player is
            ["Level"] = 0,                      -- Player's level/rank in-game
            ["Skin"] = "Delinquent",            -- Equipped skin
            ["SkinInv"] = {{"Delinquent", 1}},  -- All skins
            ["Melees"] = "Dagger",              -- Equipped melee
            ["MeleeInv"] = {{"Dagger", 1}},     -- All melees
            ["Codes"] = {}                      -- Redeemed codes
        }
    else -- Returning player
        local success, fail = pcall(function()
            wait(5)
            Data[player] = HttpService:JSONDecode(DataStore:GetAsync(key))
        end)

        if not success then -- Data load error
            warn("Unexpected error loading Player (" .. player.Name .. ") data\n Error: " .. fail)
            player:Kick("Error loading your data, please try a rejoining or joining a different server.\n If this continues, contact us via social media. Thank you.")
        end
    end

    Instance.new("Folder", player).Name = "Status"                  -- Current player match data (including the current player's team, level, points, etc.)
    Instance.new("Folder", player).Name = "Data"                    -- Player's data (includes settings, inventory, saved statuses, etc.)

    Instance.new("Folder", player.Data).Name = "Inventory"          -- Has all inventory aspects 
    Instance.new("Folder", player.Data.Inventory).Name = "Skins"    -- Owned skins
    Instance.new("Folder", player.Data.Inventory).Name = "Melees"   -- Owned melees
    Instance.new("StringValue", player.Data).Name = "Skin"          -- Current equipped skin
    Instance.new("StringValue", player.Data).Name = "Melee"         -- Current equipped melee
    Instance.new("IntValue", player.Data).Name = "Bucks"            -- Current bucks amount (ALSO A DUMMY THING TO TROLL EXPLOITERS, ofc use the AddBucks function for stuff, but also this is to do the output stuff. NOT FOR ACTUAL USE..)
    Instance.new("IntValue", player.Data).Name = "Kills"            -- Current total kills for the entire player's lifetime. (aka. kill tracker, used for output. DOES NOTHING ELSE LOL)
    Instance.new("IntValue", player.Data).Name = "Level"            -- Current player's level (i.e via xp system)

    Instance.new("IntValue", player.Status).Name = "Level"          -- Current match level (i.e 31 = golden gun, etc.)
    Instance.new("StringValue", player.Status).Name = "Team"        -- Current team, CAN NEVER BE NIL. (If not on a team, then use Spectator)
    Instance.new("", player.Status).Name

    if player:GetRankInGroup(GroupId) >= 254 then -- Rank 254 = Admin, rank 255 = developer/owner. NEED TO MAKE A DEVELOPER RANK. KEEP THAT IN UR HEAD DUMB DUMB. -Corruptgore 1 June, 2022 10:20 PM CDT
        Instance.new("BoolValue", player).Name = "IsAdmin"
    end

    if table.find(chads, player.UserId) then
        Instance.new("BoolValue", player).Name = "IsChad"
    end

    Events.GetInventory:FireClient(player, Data[player]["SkinInv"], Data[player]["MeleeInv"])

    Events.LoadCharacter:FireSever()

    Events.ServerMessage:FireAllClients(player.Name .. " has joined", "")

    player.CharacterAdded:Connect(function(character)
        repeat wait() until character.Head:FindFirstChild("Died")
        repeat wait() until character:WaitForChild("Humanoid")
    end)
end)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: