Hello im doing data stores, everything is saving except that everytime it saves it does this until the limit is reached (i think its within the autosaves code, every 30 seconds)
https://gyazo.com/647823dc25c5b21d5c566769112cfd1a
Ive put a print command in their before and its done the same thing. It first prints once, then twice, then 3 times and so on until the request is full.
local DataStoreService = game:GetService("DataStoreService")
local DataStore = DataStoreService:GetDataStore("PlayerData")
game.Players.PlayerAdded:Connect(function(Plr)
local stats = Instance.new("Folder", Plr)
stats.Name = "Stats"
--- Level System
local Level = Instance.new("NumberValue", stats)
Level.Name = "Level"
Level.Value = 1
local Exp = Instance.new("NumberValue", stats)
Exp.Name = "Exp"
Exp.Value = 0
local ExpNeed = Instance.new("IntValue", stats)
ExpNeed.Name = "ExpNeed"
ExpNeed.Value = 100
--- Money and Spin System
local Yen = Instance.new("IntValue", stats)
Yen.Name = "Yen"
Yen.Value = 0
local Spins = Instance.new("NumberValue", stats)
Spins.Name = "Spins"
Spins.Value = 5
--- Stats System
local Points = Instance.new("NumberValue", stats)
Points.Name = "Points"
Points.Value = 3
local MaxHealth = Instance.new("IntValue", stats)
MaxHealth.Name = "MaxHealth"
MaxHealth.Value = 100
local Stamina = Instance.new("IntValue", stats)
Stamina.Name = "Stamina"
Stamina.Value = 0
local Quirk = Instance.new("StringValue", game.StarterGui.Values)
Quirk.Name = "Abillity"
Quirk.Value = "Quirkless"
--- Fame
local leaderstats = Instance.new("Folder",Plr)
leaderstats.Name = "leaderstats"
leaderstats.Parent = Plr
local Fame = Instance.new("IntValue")
Fame.Name = "Fame"
Fame.Value = 0
Fame.Parent = leaderstats
spawn(function()
wait(4)
local StaminaBarMax = Instance.new("IntValue",stats)
StaminaBarMax.Name = "AbilityStaminaMax"
StaminaBarMax.Value = 100 + (Plr.Stats.Stamina.Value*5)
local StaminaBar = Instance.new("IntValue",stats)
StaminaBar.Name = "AbilityStamina"
StaminaBar.Value = StaminaBarMax.Value
end)
local Strength = Instance.new("IntValue", stats)
Strength.Name = "Strength"
Strength.Value = 0
local playerdata = {
Fame = Fame.Value,
Quirk = Quirk.Value,
Stamina = Stamina.Value,
MaxHealth = MaxHealth.Value,
Points = Points.Value,
Spins = Spins.Value,
Yen = Yen.Value,
ExpNeed = ExpNeed.Value,
Exp = Exp.Value,
Level = Level.Value,
Strength = Strength.Value
}
local data
local success, errormessage = pcall(function()
Data = DataStore:GetAsync(Plr.UserId)
end)
if success then
if Data then
playerdata.Fame = Data.Fame
playerdata.Quirk = Data.Quirk
playerdata.Stamina = Data.Stamina
playerdata.MaxHealth = Data.MaxHealth
playerdata.Points = Data.Points
playerdata.Spins = Data.Spins
playerdata.Yen = Data.Yen
playerdata.ExpNeed = Data.ExpNeed
playerdata.Exp = Data.Exp
playerdata.Level = Data.Level
playerdata.Strength = Data.Strength
end
end
Fame.Value = playerdata.Fame
Quirk.Value = playerdata.Quirk
Stamina.Value = playerdata.Stamina
MaxHealth.Value = playerdata.MaxHealth
Points.Value = playerdata.Points
Spins.Value = playerdata.Spins
Yen.Value = playerdata.Yen
ExpNeed.Value = playerdata.ExpNeed
Exp.Value = playerdata.Exp
Level.Value = playerdata.Level
Strength.Value = playerdata.Strength
while wait(30) do
game.ReplicatedStorage.QuirkSpinner.QuirkSetter:FireClient(Plr)
game.ReplicatedStorage.QuirkSpinner.QuirkSetter.OnServerEvent:Connect(function(player,Ability)
playerdata.Fame = Fame.Value
playerdata.Quirk = Ability
playerdata.Stamina = Stamina.Value
playerdata.MaxHealth = MaxHealth.Value
playerdata.Points = Points.Value
playerdata.Spins = Spins.Value
playerdata.Yen = Yen.Value
playerdata.ExpNeed = ExpNeed.Value
playerdata.Exp = Exp.Value
playerdata.Level = Level.Value
playerdata.Strength = Strength.Value
DataStore:SetAsync(Plr.UserId, playerdata)
return
end)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
game.ReplicatedStorage.QuirkSpinner.QuirkSetter:FireClient(player)
game.ReplicatedStorage.QuirkSpinner.QuirkSetter.OnServerEvent:Connect(function(player,Ability)
local playerdata = {}
local Fame = player.leaderstats.Fame
local stats = player.Stats
local quirk = Ability
local Stamina = stats.Stamina
local MaxHealth = stats.MaxHealth
local Points = stats.Points
local Spins = stats.Spins
local Yen = stats.Yen
local ExpNeed = stats.ExpNeed
local Exp = stats.Exp
local Level = stats.Level
local Strength = stats.Strength
playerdata.Fame = Fame.Value
playerdata.Quirk = quirk.Value
playerdata.Stamina = Stamina.Value
playerdata.MaxHealth = MaxHealth.Value
playerdata.Points = Points.Value
playerdata.Spins = Spins.Value
playerdata.Yen = Yen.Value
playerdata.ExpNeed = ExpNeed.Value
playerdata.Exp = Exp.Value
playerdata.Level = Level.Value
playerdata.Strength = Strength.Value
local success, errormessage = pcall(function()
DataStore:SetAsync(player.UserId, playerdata)
end)
if success then
print("DataSaved")
else
print("Data Failed To Save")
warn(errormessage)
end
end)
end)
game.Players.PlayerAdded:Connect(function(player)
wait(5)
local Exp = player.Stats.Exp
local Level = player.Stats.Level
local Points = player.Stats.Points
local ExpNeed = player.Stats.ExpNeed
Exp.Changed:Connect(function()
while Exp.Value >= ExpNeed.Value and Level.Value <= 1999 do
wait(0.4)
print("Levels")
if Exp.Value >= ExpNeed.Value and Level.Value <= 1999 then --and Level.Value <= 1999
Level.Value = Level.Value + 1
Points.Value = Points.Value + 3
Exp.Value = Exp.Value - ExpNeed.Value
ExpNeed.Value = ExpNeed.Value + 100
local levelup = script:WaitForChild("Level Up"):Clone()
local particle = script:WaitForChild("particle"):Clone()
particle.Name = player.Name .."'s LevelUp Particle"
spawn(function()
particle.Parent = workspace
particle.CFrame = player.Character.HumanoidRootPart.CFrame
wait(0.4)
particle.particle.LevelUp.Rate = 0
end)
levelup.Parent = player.Character.HumanoidRootPart
levelup:Play()
local detroy = game:GetService("Debris")
detroy:AddItem(levelup,1)
detroy:AddItem(particle,3)
wait(.4)
end
wait(.4)
end
end)
end)