GUI Not Updating

Hey, I just made it so my game saves data. Now I’m trying to figure out how to get my GUI to update with this data rather than show what a new player would see.

For example, in the game when you level up it unlocks the ability to teleport to the next area.


My character has levelled up to this point, but the GUI doesn’t recognize it.

I thought this would be a simple fix, but I can’t get it to work for some reason.
Here’s the code I’ve tried:

players.PlayerAdded:Connect(function()
if level >= 1 then
		MoonRod.Visible = true
		LOCKEDRod.Visible = false
		lockedTP.Visible = false
		CloudTP.AutoButtonColor = true
		board.TextLabel.Text = "Apprentice"
	end

These are all the things that should be updated when you level up. I first tried this code in my GuiScript (StarterGui > Main > GuiScript). When that didn’t work, I changed it to:

players.PlayerAdded:Connect(function()
player.CharacterAdded:Connect(function()
...yatta yatta

Still no luck. So I also tried both in StarterPlayerScripts because why not but that didn’t work either lol.

Anyone know how to fix this?

1 Like

Are you using a local script or a server script? I don’t think you even need PlayerAdded in the script as you can simply get the local player and and check the level, then the script does the rest.

For example:

local player = game.Players.LocalPlayer
local level = player:WaitForChild("Level") -- not sure where 'Level' is exactly located

if level.Value >= 1 then -- checks if value of 'Level' is 1 or over
	-- runs the rest of the code
end
2 Likes

A local script, I just tried to do it on a a server script but can’t figure out how to grab the level value (wait for child just says ‘attempt to index nil’)

thanks for the tip on the PlayerAdded, I forgot you don’t actually need a function to make stuff happen! :joy:

edit: Actually running it on a local script like this under starterplayerscripts did work for the billboard gui I have on the player. The other gui still didn’t update though.

2 Likes

Also not sure I made it clear, the GUI works properly in a one sitting basis. If I level up the character through the game it all works properly.

The problem is getting it to recognize saved data when the player joins and updating accordingly.

1 Like

What code do you have to make it work in one sitting? It should just be a case of the client script reading the value and running the same update function / logic as if the player just levelled up.

1 Like

Well I have it all tied to a level up button

When you click the button after loading in it does update everything properly. But obviously it’s not ideal to need to click that every time you load in.

1 Like

Okay but what about the code that does that? I’m guessing you have a function connected to the activated event of the button. You may be able to just run that function once at the start

2 Likes

Oh, I see what you’re saying! Well it’s actually working properly now lol.

With my astounding negligence I didn’t try BabyNinjaTime’s corrected code at it’s original place in the gui script.

Thanks for the help!!

2 Likes