Trying to make a rebirth system and the only problems are that when rebithed, the GUI's text doesn't change instantly and the players data doesn't change instantly. I would have to re-open the rebirth tab for it to update the text and I would have to leave and rejoin for it to update the player data
This code that is managing the gui for rebirthing
local player = game.Players.LocalPlayer
local RepStor = game:GetService("ReplicatedStorage")
local RebirthFunction = RepStor:WaitForChild("RebirthFunction")
local openRebirthFrame = script.Parent.StatusFrame.Rebrith2:WaitForChild("RebirthOpenButton")
local rebirthFrame = script.Parent.SecondFrame:WaitForChild("RebirthFrame")
local rebirthButtonVar = rebirthFrame.RebirthText:WaitForChild("RebirthButton")
local leaderstats = player:WaitForChild("leaderstats")
local Rebirths = leaderstats:WaitForChild("Rebirths")
function rebirthButton()
rebirthFrame.Visible = not rebirthFrame.Visible
rebirthFrame.MultiplierInfo.Text = "Your new multiplier will be " .. Rebirths.Value * 2 .. "X"
end
openRebirthFrame.MouseButton1Up:Connect(rebirthButton)
function rebirth()
local playerRebirthed = RebirthFunction:InvokeServer()
if playerRebirthed == true then
player.RebirthMultipler.Value = player.RebirthMultipler.Value * 2
rebirthFrame.MultiplierInfo.Text = "Your new multiplier will be " .. Rebirths.Value * 2 .. "X"
end
end
rebirthButtonVar.MouseButton1Up:Connect(rebirth)
This code that is resting the players data
RebirthFunction.OnServerInvoke = function(player)
local initKey = "user_" .. player.userId .. "_init"
local coinsKey = "user_" .. player.userId .. "_coins"
local invenValKey = "user_" .. player.userId .. "_invenVal"
local invenCountKey = "user_" .. player.userId .. "_invenCount"
local backpackKey = "user_" .. player.userId .. "_backpack"
local pickaxeKey = "user_" .. player.userId .. "_pickaxe"
local boughtKey = "user_" .. player.userId .. "_bought"
if player.leaderstats.Coins.Value >= 10000000 then
player.leaderstats.Rebirths.Value = player.leaderstats.Rebirths.Value + 1
dataStore:SetAsync(initKey, true)
dataStore:SetAsync(coinsKey, 0)
dataStore:SetAsync(invenValKey, 0)
dataStore:SetAsync(invenCountKey, 0)
dataStore:SetAsync(backpackKey, "BackpackBasic")
dataStore:SetAsync(pickaxeKey, "Basic Pickaxe")
dataStore:SetAsync(boughtKey, {})
end
end

1 comment
try adding a while wait(0.1) do so the text constantly changes with the value