My game leaderstats created 2 times for no reason.
Image
Leaderstats Script
local groupid = 10830638
local DB = game:GetService("DataStoreService");
local MinDB = DB:GetDataStore("MinStats");
game.Players.PlayerAdded:connect(function(player)
local leaderstats = Instance.new("Folder", player);
leaderstats.Name = "leaderstats";
local Minutes = Instance.new("IntValue", leaderstats);
local Coins = Instance.new("IntValue", leaderstats);
local Rebirth = Instance.new("IntValue", leaderstats)
local Gems = Instance.new("IntValue", leaderstats)
Minutes.Name = "Minutes";
Coins.Name = "Coins";
Rebirth.Name = "Rebirth";
Gems.Name = "Gems";
Minutes.Value = 0;
pcall(function()
Minutes.Value = MinDB:GetAsync(player.UserId) or 0;
end)
coroutine.wrap(function()
while wait(60) do
Minutes.Value = Minutes.Value + 1;
end
end)()
end)
game.Players.PlayerRemoving:connect(function(player)
pcall(function()
if (player:FindFirstChild("leaderstats")) then
MinDB:SetAsync(player.UserId, player.leaderstats.Minutes.Value);
end
end)
end)
I even try with “Find All/Replace All” to find leaderstats
, rebirths
and more keywords which you need when create a new leaderstats. But no clue…