I need help with adding to this cript a limit (Like if you charge you charge charge charge and then it stops when the value of the ki is 100):
local plr = game.Players.LocalPlayer; repeat wait(1) until plr.Character; local char = plr.Character; local mouse = plr:GetMouse(); local down = 0; local charging = 0; local cd = 1; local max = script:WaitForChild("MaxKi"); local Ki = plr.PlayerGui:WaitForChild("Ki"); local Cost = script:WaitForChild("Cost"); local maxxing = 0; local hum = char.Humanoid function effect() local AuraClone = game.Lighting.ChargingAura:Clone() AuraClone.Parent = char.Torso end function effectend() local CloneAura = char.Torso.ChargingAura CloneAura:Remove() end local UIS = game:GetService("UserInputService") UIS.InputBegan:connect(function(input,gp) if input.UserInputType == Enum.UserInputType.Keyboard and not gp then if input.KeyCode == Enum.KeyCode[script.Key.Value] then if cd == 1 then if plr.Character.Humanoid.Health > 0 then if Ki.Value < max.Value then down = 1; effect(); end; end; end; end; end; end); UIS.InputEnded:connect(function(input,gp) if input.UserInputType == Enum.UserInputType.Keyboard and not gp then if input.KeyCode == Enum.KeyCode[script.Key.Value] then down = 0; effectend(); end; end; end); while wait() do if down >= 1 then if plr.Character.Humanoid.Health > 0 then if Ki.Value > 0 then Ki.Value = Ki.Value + Cost.Value; charging = charging + 1; end; end; end; end;
local function recharge(hum, rate, limit) while hum.Health > 0 and hum.Health + rate <= limit do hum.Health = hum.Health + rate end end