After my Chrackter Dies The Level Gui dont work anymore
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)
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
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