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

Players getting Credits but GUI not updating?

This is the only script that is having issues:

local lib = assert(LoadLibrary("RbxUtility"))
pgui = script.Parent.Parent

script.Parent.Changed:connect(function(val)
	local credittab = lib.DecodeJSON(script.Parent.Value)
	pgui.FrameDesign.Design.Credits.TextLabel.Text = credittab.credits .. " Credits"
end)

I have a JSON string (I'm encoding it in JSON because I was asked to) in PlayerGui named "Creds" under which there is the above script. All the other scripts work fine, and the "Creds" value updates on the payday. This is the only issue.

pgui.FrameDesign.Design.Credits.TextLabel is the TextLabel that I want to display the number of Credits the player has.

This exact script used to function perfectly, but all of a sudden, without making any changes, it has stopped working, and I cannot fathom why.

EDIT 1:

In case you wanted to see it, here is the Payday script:

group = 1051234
lp = script.Parent.Parent
local lib = assert(LoadLibrary("RbxUtility"))

if lp:IsInGroup(group) then
	payday = 3
elseif not lp:IsInGroup(group) then
	payday = 1
end

if lp.userId == 18001656 or lp.userId == 32172098 then
	payday = 25
end

time = 5

while true do
	wait(1)
	time = time - 1
	if time == 0 then
		time = 5
		if lp.PlayerGui.Creds.Value ~= "0" then
			local credittab = lib.DecodeJSON(lp.PlayerGui.Creds.Value)
			credittab.credits = credittab.credits + payday
			lp.PlayerGui.Creds.Value = lib.EncodeJSON(credittab)
		else
			local credittab = {
				credits = payday
			}
			lp.PlayerGui.Creds.Value = lib.EncodeJSON(credittab)
		end
	end
end

EDIT 2:

Here is a script that (is supposed to) keep the Player's Credits on death. Perhaps it is the issue?

local lib = assert(LoadLibrary("RbxUtility"))

game.Players.PlayerAdded:connect(function(p)
	p.Character.Humanoid.Died:connect(function()
		local credittab = lib.DecodeJSON(p.PlayerGui.Creds.Value)
		repeat wait() until p.Character
		wait(1)
		p.PlayerGui.Creds.Value = lib.EncodeJSON(credittab)
	end)
end)

1 answer

local lib = assert(LoadLibrary("RbxUtility"))
pgui = script.Parent.Parent

script.Parent.Changed:connect(function(val)
    local credittab = lib.DecodeJSON(script.Parent.Value)
    pgui.FrameDesign.Design.Credits.TextLabel.Text = (tostring)credittab.credits .. " Credits"
end)

It may work, i'm not 100% sure but that is what I would try.

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