#How reset all stats

1 messages · Page 1 of 1 (latest)

glad marsh
#

I would like to reset the stats for everyone even those who are not currently in the game

#

pls guys it is urgent

red token
#

just reset everyone's data or change the data key to something new

glad marsh
#

How @red token (sorry im not a pro)

red token
#

but this wont help if theyre not ingame, idk what datastorage you're using

glad marsh
#

Ok so how i change the data Key to something New @red token

glad marsh
#

@red token pls

bold shard
#

Like how you would change it the first time

glad marsh
bold shard
glad marsh
#

ok i will try, thank you so much 🙏

bold shard
#

np

glad marsh
#

what no?

bold shard
#

I mean no problem

#

Stupid auto correct

glad marsh
#

eh it is doesn't work

#

@bold shard i change but it is doesn't work

bold shard
glad marsh
#

yes

bold shard
#

Yeah thats a completely separate datastore

#

You would have to reset that

glad marsh
#

?

#

i change the name

#

But it is doesn't work

bold shard
#

The leaderstats use a different datastore

#

Thats not adonis

glad marsh
#

oh

#

so how i do

bold shard
#

So everyone is on 0

glad marsh
#

where

bold shard
#

Where the leaderstats datastore is handled

#

Should be in ServerScriptService

glad marsh
#

ok

#

--[[Savin'
Dem
Stats
--]]
game.Players.PlayerRemoving:connect(function(player)
local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")

local statstorage = player:FindFirstChild("leaderstats"):GetChildren()
for i = 1, #statstorage do
datastore:SetAsync(statstorage[i].Name, statstorage[i].Value)
print("saved data number "..i)

end
print("Stats successfully saved")
end)

--[[
Loadin'
Dem
Stats
--]]
game.Players.PlayerAdded:connect(function(player)
local datastore = game:GetService("DataStoreService"):GetDataStore(player.Name.."Stats")

player:WaitForChild("leaderstats")
wait(1)
local stats = player:FindFirstChild("leaderstats"):GetChildren()
for i = 1, #stats do            
stats[i].Value = datastore:GetAsync(stats[i].Name)
print("stat numba "..i.." has been found")
    end

end)

#

what i change

bold shard
#

"Stats"

glad marsh
#

Ok

#

I have another script in the serverscript service that adds stats every minute, do I have to change things in it?

#

game.Players.PlayerAdded:connect(function(p)
local stats = Instance.new("IntValue", p)
stats.Name = "leaderstats"
local money = Instance.new("IntValue", stats)
money.Name = "XP"
money.Value = 0
while true do
wait(300)
money.Value = money.Value + 50
end
end)

bold shard
#

Unless the script breaks then show the error