Quick Question: I have a game not published publically but only certain users can access it (Developers, Testers, and Paid-Access). They are having an issue with the point save system, where their in-game points are not saving. Could this be because it is not published or is it my scripts issue?
Script:```
local DataStoreService = game:GetService(“DataStoreService”)
local myDataStore = DataStoreService:GetDataStore(“myDataStore”)
game.Players.PlayerAdded:Connect(function(player)
local leaderstats1 = Instance.new(“Folder”)
leaderstats1.Name = “leaderstats1”
leaderstats1.Parent = player
local points = Instance.new("IntValue")
points.Name = "ElitePoints"
points.Parent = leaderstats1
local value = game.ServerStorage.mate
repeat wait()
wait(30)
points.Value = points.Value + 1
until value.Value == true
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(player.UserId.."-points")
end)
if success then
points.Value = data
else
print("Error")
warn(errormessage)
end
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-points",player.leaderstats1.ElitePoints.Value)
end)
if success then
print("Success")
else
print("Error")
warn(errormessage)
end
end)
(PS:I have no idea why my code bricks are like this)
did you patiently wait long enough? The script says that every 30 second a point will increase until mate.Value == true
Even when mate.Value == true, you have to wait until the last 30 second ends.
Also, the script wont continue until that repeat function ends.
Well I just found out what my issue was and should have spent more time thinking, My code
local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats1 = Instance.new("Folder")
leaderstats1.Name = "leaderstats1"
leaderstats1.Parent = player
local points = Instance.new("IntValue")
points.Name = "ElitePoints"
points.Parent = leaderstats1
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(player.UserId.."-points")
end)
if success then
points.Value = data
else
print("Error")
warn(errormessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-points",player.leaderstats1.ElitePoints.Value)
end)
if success then
print("Success")
else
print("Error")
warn(errormessage)
end
end)
game.Players.PlayerAdded:Connect(function(player)
local points = player:WaitForChild("leaderstats1"):WaitForChild("ElitePoints")
local value = game.ServerStorage.mate
repeat wait()
wait(30)
points.Value = points.Value + 1
until value.Value == true
end)