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:
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
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!
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.
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.
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.
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