Hi,
I've recently started using DataStoreService for the first time, and wanted to implement them into my game to store users' Credits. It doesn't seem to error anywhere else, but it fails to get the player's data when they join the game.
Here's my code:
local DSS = game:GetService("DataStoreService") local playerCreditScore = DSS:GetDataStore("playerCreditScore") game.Players.PlayerAdded:Connect(function(Player) local leaderstats = Instance.new("Model") leaderstats.Name = "leaderstats" leaderstats.Parent = Player local Credits = Instance.new("IntValue") Credits.Name = "Credits" Credits.Parent = leaderstats local function getCredit() return playerCreditScore:GetAsync(Player.UserID) end local success, credit = pcall(getCredit) if success then Credits.Value = credit else warn("Could not get ", Player.Name,"'s credits.") end end) game.Players.PlayerRemoving:Connect(function(Player) local success = pcall(function() playerCreditScore:SetAsync(Player.UserId, Player.leaderstats.Credits.Value) end) if success then print("Successfully saved ", Player.Name,"'s credits.") else warn("Could not save ", Player.Name,"'s credits.") end end)
FYI, the game has Filtering Enabled enabled.
Thanks