Hi. In my game I have a basic datastore for wins and coins. For about a year it has all worked fine. Suddenly it’s not working and I’m not sure why and don’t know how to fix the situation. Here is some info:
1. Code:
Server - MainScript:
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
local WinsLeaderboard = DataStoreService:GetOrderedDataStore("WinsLeaderboard")
local CoinsLeaderboard = DataStoreService:GetOrderedDataStore("CoinsLeaderboard")
Players.PlayerAdded:Connect(function(player)
AFK = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
player.CharacterAdded:Wait()
print(player.Name .. " joined the game!")
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local wins = Instance.new("StringValue")
wins.Name = "Wins"
wins.Parent = leaderstats
local coins = Instance.new("StringValue")
coins.Name = "Coins"
coins.Parent = leaderstats
print ("leaderstats done!")
local winsdata
local success, errormessage = pcall(function()
winsdata = myDataStore:GetAsync(player.UserId.."-wins")
end)
if success then
wins.Value = winsdata
print ("player added and wins data was retrieved")
print (player.Name)
print (wins.Value)
else
print("There was an error while getting your data")
warn(errormessage)
end
local coinsdata
local success, errormessage = pcall(function()
coinsdata = myDataStore:GetAsync(player.UserId.."-coins")
end)
if success then
coins.Value = coinsdata
print ("player added and coins data was retrieved")
print (player.Name)
print (coins.Value)
else
print("There was an error while getting your data")
warn(errormessage)
end
if coinsdata ~= nil then
coins.Value = coinsdata
print ("Coins Data Loaded")
else
-- New Player
coins.Value = 40
print ("new player to game")
end
-----
WinsLeaderboard:SetAsync(player.UserId, tonumber(player.leaderstats.Wins.Value))
CoinsLeaderboard:SetAsync(player.UserId, tonumber(player.leaderstats.Coins.Value))
… more code to follow that isn’t relevant to share…
LocalScript:
local player = game:GetService("Players")
script.Parent.TextLabel.Text = player:WaitForChild("leaderstats").Coins.Value
print(player:WaitForChild("leaderstats").Coins.Value)
2. Evidence it’s not working:
Here’s is my output from Roblox Studio after running:
11:30:31.626 coopersfather joined the game! - Server - MainScript:116
11:30:31.626 leaderstats done! - Server - MainScript:133
11:30:31.770 player added and wins data was retrieved - Server - MainScript:146
11:39:14.504 coopersfather - Server - MainScript:147
11:39:14.504 Expected ‘:’ not ‘.’ calling member function GetAsync - Server - MainScript:148
11:30:31.923 player added and coins data was retrieved - Server - MainScript:159
11:39:14.647 coopersfather - Server - MainScript:162
11:39:14.647 100 - Server - MainScript:163
11:30:31.923 Coins Data Loaded - Server - MainScript:169
11:30:32.040 Argument 2 missing or nil - Server - MainScript:199
11:21:27.770 Infinite yield possible on ‘Players:WaitForChild(“leaderstats”)’ - LocalScript:6
3. Other details:
I reverted back to an older version of my game way back in September when everything was working and it still produces the same errors
Data retrieval for coins seems to work but not wins.
Any help would be greatly appreciated!
Kevin