local Players = game:GetService("Players") local NexusData = require(game.ServerScriptService.NexusData) local PlayerStore = NexusData.CreateStore("NexusPlayerData_v1", { Coins = 0, Level = 1, XP = 0, Inventory = {}, Settings = { Music = true, SFX = true, }, }, { SchemaVersion = 1, }) local function loadPlayer(player) local profile, err = PlayerStore:LoadProfileAsync(player.UserId) if not profile then warn(("NexusData failed to load %s: %s"):format(player.Name, tostring(err))) player:Kick("We couldn't load your data safely. Please rejoin.") return end print(("Loaded %s with %d coins"):format(player.Name, profile:Get("Coins", 0))) player:SetAttribute("NexusDataLoaded", true) profile:Increment("Coins", 25) end Players.PlayerAdded:Connect(loadPlayer) for _, player in Players:GetPlayers() do task.spawn(loadPlayer, player) end Players.PlayerRemoving:Connect(function(player) PlayerStore:ReleaseProfile(player.UserId) end) game:BindToClose(function() NexusData.CloseAll() end)