Stats UI script only stops working after the player resets

  1. What do you want to achieve? A stats UI script that displays the players current stamina level.

  2. What is the issue? The script works fine the first time, then stops working the second time after the player resets. (don’t mind my horrible lag in the video :sob: my laptop decides to not work with the screen recorder)
    Streamable

  3. What solutions have you tried so far? I’ve tried looking for similar topics and changing my code but nothing has worked yet.

Here’s the script

local TweenService = game:GetService("TweenService")
local player = game.Players.LocalPlayer
local character = player.Character
local Gui = script.Parent.Energy

local energy = character:GetAttribute("Energy")
local max = character:GetAttribute("MaxEnergy")

while true do
	task.wait()
	
	local energy = character:GetAttribute("Energy")
	local max = character:GetAttribute("MaxEnergy")
	
	local percent = math.floor((energy/max)*100)/100
	
	TweenService:Create(Gui, TweenInfo.new(1,Enum.EasingStyle.Quad), {Size = UDim2.new(percent,0,0.625,0)}):Play()
end

all help is appreciated

Is the GUI’s ResetOnDeath value to true? If it is make it false

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.