-
What do you want to achieve? I want to achieve that you don’t need to rejoin to gain cash every 0.1 seconds
-
What is the issue? The issue is that if you join the first time in the game it doesn’t give the money but you have the multiplier that grants you the money, if you rejoin it gives the money
Script:
local Short = require(game.ReplicatedStorage.Short)
local datastoreservice = game:GetService("DataStoreService")
local mydatastore = datastoreservice:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Level = Instance.new("NumberValue")
Level.Name = "Level"
Level.Value = 0
Level.Parent = leaderstats
local currencies = Instance.new("Folder")
currencies.Name = "currencies"
currencies.Parent = player
local Money = Instance.new("NumberValue")
Money.Name = "Money"
Money.Value = 0
Money.Parent = currencies
local Multiplier = Instance.new("NumberValue")
Multiplier.Name = "Multiplier"
Multiplier.Value = 1
Multiplier.Parent = currencies
local Rebirth = Instance.new("NumberValue")
Rebirth.Name = "Rebirth"
Rebirth.Value = 0
Rebirth.Parent = currencies
local UltraRebirth = Instance.new("NumberValue")
UltraRebirth.Name = "UltraRebirth"
UltraRebirth.Value = 0
UltraRebirth.Parent = currencies
local Prestige = Instance.new("NumberValue")
Prestige.Name = "Prestige"
Prestige.Value = 0
Prestige.Parent = currencies
local MegaRebirth = Instance.new("NumberValue")
MegaRebirth.Name = "MegaRebirth"
MegaRebirth.Value = 0
MegaRebirth.Parent = currencies
local GigaRebirth = Instance.new("NumberValue")
GigaRebirth.Name = "GigaRebirth"
GigaRebirth.Value = 0
GigaRebirth.Parent = currencies
local UltraPrestige = Instance.new("NumberValue")
UltraPrestige.Name = "UltraPrestige"
UltraPrestige.Value = 0
UltraPrestige.Parent = currencies
local playerUserId = "Player_"..player.UserId
-- loads DATA
local data
local success, errormessage = pcall(function()
data = mydatastore:GetAsync(playerUserId)
end)
if success then
Money.Value = data.Money or 0
Multiplier.Value = data.Multiplier or 1
Rebirth.Value = data.Rebirth or 0
UltraRebirth.Value = data.UltraRebirth or 0
Prestige.Value = data.Prestige or 0
MegaRebirth.Value = data.MegaRebirth or 0
GigaRebirth.Value = data.GigaRebirth or 0
UltraPrestige.Value = data.UltraPrestige or 0
Level.Value = data.Level or 0
end
while wait(0.1) do
Money.Value = Money.Value + (1*Multiplier.Value)
Level.Value = ((math.log10(Money.Value+1)*0.001)+((math.log10(Multiplier.Value)*0.01))+((math.log10(Rebirth.Value+1)*0.1))+((math.log10(UltraRebirth.Value+1)*1))+((math.log10(Prestige.Value+1)*10))+((math.log10(MegaRebirth.Value+1)*100))+((math.log10(GigaRebirth.Value+1)*1000))+((math.log10(UltraPrestige.Value+1)*10000)))
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "Player_"..player.UserId
local data = {
Money = player.currencies.Money.Value;
Multiplier = player.currencies.Multiplier.Value;
Rebirth = player.currencies.Rebirth.Value;
UltraRebirth = player.currencies.UltraRebirth.Value;
Prestige = player.currencies.Prestige.Value;
MegaRebirth = player.currencies.MegaRebirth.Value;
GigaRebirth = player.currencies.GigaRebirth.Value;
UltraPrestige = player.currencies.UltraPrestige.Value;
Level = player.leaderstats.Level.Value
}
local success, errormessage = pcall(function()
mydatastore:SetAsync(playerUserId, data)
end)
if success then
print("Data succesfully saved!")
else
print("There was an error!")
warn(errormessage)
end
end)
