GUI Local Script Dont work after Chrackter Died

After my Chrackter Dies The Level Gui dont work anymore :frowning:

It seems like the script is getting deactivated after the player dies and the values are getting back to standard. leveling is still working only my gui is getting deactivated like there is no player anymore and cant get the values from the player.

My local Script for my Level Gui

-- Player-related variables.
local player = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()

local level = player:WaitForChild("Lv")
local current = level:WaitForChild("Exppp")
local max = level:WaitForChild("MaxExppp")

-- UI-related variables.
local gui = script.Parent
local exterior = gui:WaitForChild("Exterior")
local label = exterior:WaitForChild("Label")
local exp = exterior:WaitForChild("Exp")
local bar = exterior:WaitForChild("Bar")

-- Change stats upon join.

	label.Text = "Level "..level.Value
	exp.Text = current.Value.."/"..max.Value.." EXP"
	bar.Size = UDim2.new(current.Value/max.Value, 0, 1, 0)


level.Changed:Connect(function(val)
	label.Text = "Level "..level.Value
	exp.Text = current.Value.."/"..max.Value.." EXP"
	bar.Size = UDim2.new(current.Value/max.Value, 0, 1, 0)
end)

current.Changed:Connect(function(val)
	exp.Text = current.Value.."/"..max.Value.." EXP"
	bar.Size = UDim2.new(current.Value/max.Value, 0, 1, 0)	
end)

2 Likes

Do you have any errors in the output?

no there is no error in the output :confused:

You can turn off ResetOnSpawn on your gui.

2 Likes

you didn’t make an error, maybe it is from the UI its self or maybe you weren’t specific enough?

i tried this but nothing changed

The Script is starting again after my chrackter dies (i checked it) but nothing happends in the gui there is no reaction from UI

have you tried adding waitforchild?

there is everywhere waitforchild in the script

maybe thats the problem? it loops wait for child?

i tried this and nothing changes :confused:

im not sure what the problem here is all you can do is re look at your script

i just made a provment and after i die the gui is nil but why?

What do you mean the gui is nil? It doesn’t exist?

yes i think so, after i respawn the script cant find gui anymore

And you set ResetOnSpawn to false? If you did that then the gui shouldn’t disappear.

the gui is still visible but not working anymore and dont react to changes

Every content of StarterGui gets replaced after the character respawns, make sure the script is being designed to be ran again every time the gui is being replaced, check if ResetOnSpawn of the GUI is set to false, and set it to true

My roblox studio was bugged i think no i reset it and its works somehow again the gui is appering but the values do not change after charackter dies

Maybe to test you could add a while wait(1) loop at the bottom of the script that prints out things. Then reset your character and see if any of the prints change, so that you know if anything happens that could effect the script.

--at the bottom

while wait(1) do
       print("EXP: "..current.Value)
       print("level: "..level.Value)
       print(label.Name)
       print(bar.Name)
       print(exp.Name)
end