Hello.
I literally have no idea why this isn’t working. Here is my code:
local players = game:GetService("Players")
local DSService = game:GetService("DataStoreService")
local database = DSService:GetDataStore("TestDatabase")
local function playerAdded(player)
local leaderstats = Instance.new("Configuration", player)
leaderstats.Name = "leaderstats"
local Cash = Instance.new("NumberValue", leaderstats)
Cash.Value = database:GetAsync("Cash-"..player.userId) or 0
Cash.Name = "Cash"
local Relocation = Instance.new("NumberValue", leaderstats)
Relocation.Value = database:GetAsync("Relocation-"..player.userId) or 0
Relocation.Name = "Relocation"
end
local function playerRemoving(player)
database:SetAsync("Cash-"..player.userId, player.leaderstats.Cash.Value)
database:SetAsync("Relocation-"..player.userId, player.leaderstats.Relocation.Value)
end
players.PlayerAdded:Connect(playerAdded)
players.PlayerRemoving:Connect(playerRemoving)
Here is a studio screenshot to show I’m not going insane:
Hopefully one of you can point me in the right direction.
- Ham