this is the code located in a script in starter gui (also in starter gui is a ScreenGui, 'Staminabar', in which inside that is a frame 'Frame'
local Player = Tool.Parent.Parent -- tool is inside backpack which is inside player local Stamina = game.StarterGui.Staminabar.Frame local RemoteEvent = game.StarterGui.Staminabar.Frame.RemoteEvent -- not sure where you have these things so I left them as empty variables, for the sake of the example local Equipped = false Tool.Equipped:Connect(function() Equipped = true -- important things pertaining to what your tool does here while true do Stamina.Value = Stamina.Value - 1 -- 1 is how much stamina is being subtracted each loop if Stamina.Value ~= 0 then RemoteEvent:FireClient(Player, Stamina.Value) -- do your gui work if Equipped = false then break end else Player.Character.Humanoid:UnequipTools() break end wait(1) end end) Tool.Unequipped:Connect(function() Equipped = false end)