alr I can send leaderstats script too.
local ReplicatedStorage = game:GetService('ReplicatedStorage')
local UpgradeSaveRemote = ReplicatedStorage.Events:WaitForChild('UpgradeSaveRemote')
local RebirthEvent = ReplicatedStorage.Events:WaitForChild('RebirthEvent')
local DataStoreService = game:GetService('DataStoreService')
local DataStore = DataStoreService:GetDataStore("DataStore")
local Players = game:GetService('Players')
Players.PlayerAdded:Connect(function(Player)
local Leaderstats = Instance.new("Folder", Player)
Leaderstats.Name = 'leaderstats'
local Freakiness = Instance.new('NumberValue', Leaderstats)
Freakiness.Name = 'Freakiness'
Freakiness.Value = 0
local Rebirths = Instance.new('NumberValue', Leaderstats)
Rebirths.Name = 'Rebirths'
Rebirths.Value = 0
local PlayerValues = Instance.new('Folder', Player)
PlayerValues.Name = 'PlayerValues'
local Multiplier = Instance.new('IntValue', PlayerValues)
Multiplier.Name = 'Multiplier'
Multiplier.Value = 1
local RebirthCost = Instance.new('IntValue', PlayerValues)
RebirthCost.Name = 'RebirthCost'
RebirthCost.Value = 3
-- Upgrades saving
local UpgradeStatus = Instance.new('Folder', Player)
UpgradeStatus.Name = 'UpgradeStatus'
local isUpgradeBought1 = Instance.new('BoolValue', UpgradeStatus)
isUpgradeBought1.Name = 'Freaky cat'
local isUpgradeBought2 = Instance.new('BoolValue', UpgradeStatus)
isUpgradeBought2.Name = 'Freaky Bob'
local isUpgradeBought3 = Instance.new('BoolValue', UpgradeStatus)
isUpgradeBought3.Name = 'Alien freak'
local isUpgradeBought4 = Instance.new('BoolValue', UpgradeStatus)
isUpgradeBought4.Name = 'Eater'
local isUpgradeBought5 = Instance.new('BoolValue', UpgradeStatus)
isUpgradeBought5.Name = 'Freaky Freddy'
local isUpgradeBought6 = Instance.new('BoolValue', UpgradeStatus)
isUpgradeBought6.Name = 'Quincy freak'
local isUpgradeBought7 = Instance.new('BoolValue', UpgradeStatus)
isUpgradeBought7.Name = 'Mahito freak'
local isUpgradeBought8 = Instance.new('BoolValue', UpgradeStatus)
isUpgradeBought8.Name = 'Extra freaky Bob'
UpgradeSaveRemote.OnServerInvoke = function(player, UpgradeValue, UpgradeName)
Player.UpgradeStatus[UpgradeName].Value = UpgradeValue
return Player.UpgradeStatus[UpgradeName].Value
end
--RebirthEvent.OnServerEvent:Connect(function(Player, RebSave, MultSave)
-- local leaderstats = Player:WaitForChild('leaderstats')
-- local Multiplier = Player.PlayerValues:WaitForChild('Multiplier')
-- local RebirthCost = Player.PlayerValues:WaitForChild('RebirthCost')
-- leaderstats.Freakiness.Value = 0
-- leaderstats.Rebirths.Value += 1
-- Multiplier.Value += 0.5
-- RebirthCost.Value *= 2
-- print('Rebirth cost server: '..RebirthCost.Value)
--end)
-- Data saving
local DataToSave = DataStore:GetAsync(Player.UserId)
if DataToSave then
Freakiness.Value = DataToSave[1]
isUpgradeBought1.Value = DataToSave[2]
isUpgradeBought2.Value = DataToSave[3]
isUpgradeBought3.Value = DataToSave[4]
isUpgradeBought4.Value = DataToSave[5]
isUpgradeBought5.Value = DataToSave[6]
isUpgradeBought6.Value = DataToSave[7]
isUpgradeBought7.Value = DataToSave[8]
isUpgradeBought8.Value = DataToSave[9]
--Rebirths.Value = DataToSave[10]
--Multiplier.Value = DataToSave[11]
--RebirthCost.Value = DataToSave[12]
else
local ValuesToSave = {
Freakiness.Value,
isUpgradeBought1.Value,
isUpgradeBought2.Value,
isUpgradeBought3.Value,
isUpgradeBought4.Value,
isUpgradeBought5.Value,
isUpgradeBought6.Value,
isUpgradeBought7.Value,
isUpgradeBought8.Value,
--Rebirths.Value,
--Multiplier.Value,
--RebirthCost.Value
}
DataStore:GetAsync(Player.UserId, ValuesToSave)
end
end)
Players.PlayerRemoving:Connect(function(Player)
local Leaderstats = Player:WaitForChild('leaderstats')
local Freakiness = Leaderstats:WaitForChild('Freakiness')
--local Rebirths = Leaderstats:WaitForChild('Rebirths')
--local Multiplier = Player.PlayerValues:WaitForChild('Multiplier')
--local RebirthCost = Player.PlayerValues:WaitForChild('RebirthCost')
local ValuesToSave = {
Freakiness.Value,
Player.UpgradeStatus:FindFirstChild('Freaky cat').Value,
Player.UpgradeStatus:FindFirstChild('Freaky Bob').Value,
Player.UpgradeStatus:FindFirstChild('Alien freak').Value,
Player.UpgradeStatus:FindFirstChild('Eater').Value,
Player.UpgradeStatus:FindFirstChild('Freaky Freddy').Value,
Player.UpgradeStatus:FindFirstChild('Quincy freak').Value,
Player.UpgradeStatus:FindFirstChild('Mahito freak').Value,
Player.UpgradeStatus:FindFirstChild('Extra freaky Bob').Value,
--Rebirths.Value,
--Multiplier.Value,
--RebirthCost.Value
}
DataStore:SetAsync(Player.UserId, ValuesToSave)
end)
game:BindToClose(function()
for i, plr in pairs(game.Players:GetChildren()) do
plr:Kick()
end
end)