Hello, Im trying to make a rebirth system and I need to save Rebirth Multiplier and Rebirth cost, but when I print Rebirth cost on server, its fine, but on client it turns 0.
Also prints that:
![]()
-- Local
local Rebirths = Leaderstats.Rebirths
local Multiplier = Player:WaitForChild('PlayerValues'):WaitForChild('Multiplier').Value
local PlayerValues = Player:WaitForChild('PlayerValues')
local RebirthCost = PlayerValues:WaitForChild('RebirthCost').Value
RebirthsPrompt.Triggered:Connect(function()
RebirthsFrame.Visible = not RebirthsFrame.Visible
RebirthsFrame.RebirthsSection.PriceValue.Text = RebirthCost..' đź‘…'
RebirthsFrame.RebirthsSection.Multiplier.Text = (Multiplier)..' x'
end)
BuyButton.MouseButton1Click:Connect(function()
if Freakiness.Value >= RebirthCost then
RebirthCost *= 2
Multiplier += 0.5
RebirthsFrame.Visible = false
RebirthEvent:FireServer(RebirthCost, Multiplier)
end
end)
-- Server
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
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 = MultSave
RebirthCost.Value = RebSave
end)
local DataToSave = DS:GetAsync(Player.UserId)
if DataToSave then
Freakiness.Value = DataToSave[1]
Variables from 2 to 9
Rebirths.Value = DataToSave[10]
Multiplier.Value = DataToSave[11]
RebirthCost.Value = DataToSave[12]
else
print('No data')
local ValuesToSave = {
Freakiness.Value,
Rebirths.Value,
Multiplier.Value,
RebirthCost.Value
}
DS:GetAsync(Player.UserId, ValuesToSave)
print('data created')
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,
Multiplier.Value,
RebirthCost.Value
}
DS:SetAsync(Player.UserId, ValuesToSave)
end)