srry if im asking to much lol, but u are pretty good scripting, so i would like to solve most of my scripting problems, im so sorry if im annoying
here let me change it up. I havent done much with slowly switching datastores this way.
here is the new script:
local dataservice = game:GetService("DataStoreService")
local statsstore = dataservice:GetDataStore("StatsData")
local oldtime = dataservice:GetDataStore("DsTime")
local oldsuricoins = dataservice:GetDataStore("SaveData")
game.Players.PlayerAdded:Connect(function(player)
local olddata = {
["Suricoins"] = oldsuricoins:GetAsync("id_"..player.UserId),
["Time"] = oldtime:GetAsync(player.UserId.."-tim")
}
local statstable = statsstore:GetAsync(player.UserId) or {}
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local cash = Instance.new("IntValue")
cash.Name = "Suricoins"
cash.Value = statstable.Suricoins or 0
cash.Parent = leaderstats
local Time = Instance.new("IntValue")
Time.Name = "Minutos"
Time.Value = statstable.Minutos or 0
Time.Parent = leaderstats
if olddata.Suricoins > 0 then
cash.Value = olddata.Suricoins
oldsuricoins:SetAsync("id_"..player.UserId, 0)
end
if olddata.Time > 0 then
Time.Value = olddata.Time
oldtime:SetAsync(player.UserId.."-tim", 0)
end
while wait(60) do
Time.Value += 1
cash.Value += 100
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local stats = {
["Suricoins"] = player.leaderstats.Suricoins.Value,
["Minutos"] = player.leaderstats.Minutos.Value
}
statsstore:SetAsync(player.UserId, stats)
end)
game:BindToClose(function()
for i,v in pairs(game.Players:GetChildren()) do
local stats = {
["Suricoins"] = v.leaderstats.Suricoins.Value,
["Minutos"] = v.leaderstats.Minutos.Value
}
statsstore:SetAsync(v.UserId, stats)
end
end)
its ok, take ur time, and if i have to give manually back the minutes to everybody, its fine
game leaderboard stills at 0 - 0 and every min it doesnt add any value
You should just use DataStore2. It’s easier and more efficient, in terms of saving data.
Get the DataStore2 module here and watch a simple tutorial on it here. I’m telling you, it’s way better than normal data stores, and it’s really easy to understand.
The DataStore2 ModuleScript is a community-made creation by @Kampfkarren.
Put this into a separate script and remove the while wait do in the 1st script. Hopefully it works better:
game.Players.PlayerAdded:Connect(function(player)
while wait(60) do
player.leaderstats.Minutos.Value += 1
player.leaderstats.Suricoins.Value += 1
end
end)
the output complains about leaderstats
it seems like there isnt a “leaderstats” folder
can you send me a screen shot?
I mean I want a screenshot of the error.
alright, do this instead:
game.Players.PlayerAdded:Connect(function(player)
while wait(60) do
player:WaitForChild("leaderstats").Minutos.Value += 1
player:WaitForChild("leaderstats").Suricoins.Value += 1
end
end)
You dont check if the player’s datastore is nil or not. If its a new player it will error
nvm this is he leaderbaord script lol
I do indeed check it. It says or {}
and later when setting the value puts or 0
.
maybe we should create the leaderstats folder
there is no leaderboard actually here:
Right there. You need to fix that part