#How reset all stats
1 messages · Page 1 of 1 (latest)
just reset everyone's data or change the data key to something new
How @red token (sorry im not a pro)
Ok so how i change the data Key to something New @red token
@red token pls
Go into the settings and change the datastore key to something else
Like how you would change it the first time
and it will reset all stats?
It will reset all data available and create new data
ok i will try, thank you so much 🙏
np
what no?
Do you use leaderstats in your game?
yes
In order to clear all data you would need to change the leaderstat's datastore
So everyone is on 0
where
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
Change stats to something else
"Stats"
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)
No
Unless the script breaks then show the error