Leaderboard updates but not the GUI

I am working on a Level up system but having trouble trying to update the GUI, while the leaderstats update when i touch the part and receive X amount of XP, the GUI itself never changes and i get the following error on the output:

Script:

local plr = game.Players.LocalPlayer

local Stats = plr:WaitForChild("leaderstats")

local function UpdateTextLabel()
	script.Parent.Text = 'Level: '..Stats.Lv.Value', Exp: '..Stats.Exp.Value..', MaxExp: '..Stats.MaxExp.Value
end

Stats.Lv.Changed:Connect(function()
	UpdateTextLabel()
	print(UpdateTextLabel)
end)

Stats.Exp.Changed:Connect(function()
	UpdateTextLabel()
	print(UpdateTextLabel)
end)

Stats.MaxExp.Changed:Connect(function()
	UpdateTextLabel()
	print(UpdateTextLabel)
end)
	script.Parent.Text = 'Level: '..Stats.Lv.Value ..', Exp: '..Stats.Exp.Value..',.. MaxExp: '..Stats.MaxExp.Value

You forgot to seperate Stats.Lv.Value’, Exp: ’

1 Like

OOF

Well updated it, i don’t get error on the output anymore but it still doesn’t change the GUI hmm

Is that a billboard gui? Or a gui

I can see its a screengui.
Is it a local script or server script?

Output already specifies that it’s a localscript, considering you’re getting no errors, are you sure you’ve changed any of the leaderstats values to toggle the Changed: event ?

Well yeah, as far as i’ve been looking, everything is fine.

GUI script:

local plr = game.Players.LocalPlayer

local Stats = plr:WaitForChild("leaderstats")

local function UpdateTextLabel()
	script.Parent.Text = 'Level: '..Stats.Level.Value..', Exp: '..Stats.Exp.Value..', MaxExp: '..Stats.MaxExp.Value
end

Stats.Level.Changed:Connect(function()	
	UpdateTextLabel()
end)

Stats.Exp.Changed:Connect(function()
	UpdateTextLabel()

end)

Stats.MaxExp.Changed:Connect(function()
	UpdateTextLabel()
end)

Leaderstats Script:

game.Players.PlayerAdded:Connect(function(player)
	
	local Folder = Instance.new("Folder")
	Folder.Name = 'leaderstats'
	Folder.Parent = player
	
	local Level = Instance.new("IntValue")
	Level.Name = 'Level'
	Level.Value = 1
	Level.Parent = Folder
	
	local Exp = Instance.new("IntValue")
	Exp.Name = 'Exp'
	Exp.Value = 0
	Exp.Parent = Folder
	
	local MaxExp = Instance.new("IntValue")
	MaxExp.Name = 'MaxExp'
	MaxExp.Value = Level.Value*1000
	MaxExp.Parent = Folder
	
	Exp.Changed:Connect(function()
		if Exp.Value >= MaxExp.Value then
			Level.Value = Level.Value + 1
			Exp.Value = 0
			MaxExp.Value = Level.Value*1000
		end
	end)
end)

I believe the error is down to your concatenation format. (..)

This should hopefully fix it:

script.Parent.Text = 'Level: ' .. Stats.Lv.Value .. ', Exp: ' .. Stats.Lv.Value .. ', MaxExp: ' .. Stats.Lv.Value

Nope, the GUI still doesn’t update :thinking:

Same thing, i used ImparuZ’s line and i managed to get the results
image

I’ll go make a full test with the UI

Copied the exact same code (except i connected with my own TextLabel) and it just works…
image
No clue what you’re doing wrong, but i’m pretty sure you did not changed the leaderstats value to have the localscript to react to the change, since it’s toggled upon Changed.

GUI :
yes.rbxm (4.2 KB)

1 Like

Well, that’s strange… i’ll keep looking around to see if i can find the issue but thanks for the help everyone

I’ve been thinking and i am curious, can it be something related to the part script? because you gain XP by tounching the part and stuff :thinking:

Script:

script.Parent.Touched:Connect(function(hit) 
	local vals = game.ReplicatedStorage.vals
	local Part = script.Parent.Parent.SecondPart
	local h = hit.Parent:FindFirstChild("Humanoid")
	if (h~=nil) then
		game.ReplicatedStorage.vals.Winner.Value = hit.Parent.Name
		local plr = game.Players[vals.Winner.Value]
		local plrChar = game.Players:GetPlayerFromCharacter(hit.Parent)
		local plrID = plrChar.UserId
		game.ReplicatedStorage.vals.Winner.Value = hit.Parent.Name
		game.ReplicatedStorage.vals.Winner.WinnerID.Value = plrID
		game.Players[vals.Winner.Value].Stats.Exp.Value = game.Players[vals.Winner.Value].Stats.Exp.Value +500
		script.Parent.Parent.StartingPoles.LeftLight.Color = Color3.fromRGB(255, 255, 255)
		script.Parent.Parent.StartingPoles.LeftLight.PointLight.Color = Color3.fromRGB(255, 255, 255)
		script.Parent.Parent.StartingPoles.RightLight.Color = Color3.fromRGB(255, 255, 255)
		script.Parent.Parent.StartingPoles.RightLight.PointLight.Color = Color3.fromRGB(255, 255, 255)
		script.Parent.Parent.CheckerFlag.BeamPart.Attachment.Beam.Color = ColorSequence.new({
			ColorSequenceKeypoint.new(0, Color3.fromRGB(255, 255, 255)),
			ColorSequenceKeypoint.new(1, Color3.fromRGB(255, 255, 255))
		  }
		)
		print(plrID)
		plr.Character.Parent = workspace
		plr:LoadCharacter()
		Part.Position = script.Parent.Position
		print(game.ReplicatedStorage.vals.Winner.Value)
		script.Parent:Destroy()
	end
end)

I recommend just making sure the Values are actually changing by looking in Explorer as client/server

shouldn’t be, because you have the following addition
game.Players[vals.Winner.Value].Stats.Exp.Value = game.Players[vals.Winner.Value].Stats.Exp.Value +500

while having print(plrID) afterward, and if the print is received, then that means there was no issue with the Exp addon (code above print)

i think you’re best off just showing the output again, or relaunching studio ?

The values are changing in both client and server explorer

image

Well i would show the output but nothing appears on it (related to this issue) and relauching studio didn’t work too, i don’t get what i did wrong, i am going nuts xD

So i discovered that if i try to change the values manually they will be updated on the GUI:

image

But if i touch the part that changes the value it will still give me 500 XP but will return to the “Label” text:

image

Your “onTouched” function is setting the value incorrectly, check there.

I don’t get what i did wrong, can you give me a tip or help me?