Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont things update live on gui and player data?

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

0

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

1 answer

Try changing your first script to this:

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
	while wait() do -- I changed it to update constantly
        	rebirthFrame.MultiplierInfo.Text = "Your new multiplier will be " .. Rebirths.Value * 2 .. "X" 
	end
    end
end
rebirthButtonVar.MouseButton1Up:Connect(rebirth)

For the Player Data, after SetAsync, have you done GetAsync?

This discussion is preserved as it was. New answers, comments, and votes are closed.