local tool = script.Parent Energy = 0 local player = game.Players.LocalPlayer tool.Equipped:connect(function(mouse) local screenGui = Instance.new("ScreenGui") screenGui.Parent = player.PlayerGui local textLabel = Instance.new("TextLabel") textLabel.Parent = screenGui textLabel.Position = UDim2.new(0, 25, 0, 50) textLabel.Size = UDim2.new(0, 150, 0, 50) textLabel.BackgroundColor3 = BrickColor.White().Color textLabel.Text = player.Name.." Sah dude"..Energy tool.Unequipped:connect(function(mouse) screenGui.Parent = nil end) end) local tool = script.Parent local keys = {} tool.Equipped:connect(function(mouse) mouse.KeyDown:connect(function(key) keys[key] = true end) mouse.KeyUp :connect(function(key) keys[key] = nil end) end) while wait(0.2) do if keys["f"] then print "Charging" Energy = Energy + 5 elseif keys["z"] and keys["x"] and Energy > 49 then print "Lol Idkek" wait(.5) Energy = Energy -50 end end
Whenever I hold down the F key, my energy increases by +5 every .2 seconds, but i would have to uneqeuip and then re-equip the tool in order for the number to change. Please help, cheers.
It's because the script you are using is in the tool, and is only executed when the tool is equipped.
In order to fix that and make it work the way you want it to, you can change the text of the label in the while loop (for everytime the energy changes).