i want it to add values to the energy value but it doesnt add
local tool = script.Parent player = game.Players:GetPlayerFromCharacter(tool.Parent) tool.Equipped:connect(function(Mouse) player = game.Players:GetPlayerFromCharacter(tool.Parent) local energy = player.PlayerGui.ScreenGui.Frame.Frame.Energy Mouse.Button1Down:connect(function() if energy.Value ~= 0 then energy.Value = energy.Value - 10 end end) if energy.Value ~=100 then while true do energy.Value = energy.Value +1 wait() end end end)
Going off of what Shawnyg said, change the while loop to:
while true do if energy.Value =100 then break() end energy.Value = energy.Value +1 wait() end