It's supposed to charge the users mana, and it does, but it doesn't stop when release the key. I have to wait until the mana reaches 100, and then I have to press the key again to stop it. How can I make it so that it stops charging when I release the key? I figure it's supposed to be like the opposite of a stamina bar used for sprinting, but I still couldn't get it to work.
01 | m = game.Players.LocalPlayer:GetMouse() -- Charging |
02 | m.KeyDown:connect( function (key) |
03 | if key = = "f" then |
04 | while Player.Character.Humanoid.Mana.Value < 100 do |
05 | game.Players.LocalPlayer.Character.Humanoid.Mana.Value = game.Players.LocalPlayer.Character.Humanoid.Mana.Value + 1 |
06 | wait( 0.01 ) |
07 | end |
08 | end |
09 | end ) |
10 |
11 | m.KeyUp:connect( function (key) -- Stop charging |
12 | if key = = "f" then |
13 | game.Players.LocalPlayer.Character.Humanoid.Mana.Value = game.Players.LocalPlayer.Character.Humanoid.Mana.Value + 0 |
14 | end |
15 | end ) |
01 | uis = game:GetService( "UserInputService" ) |
02 |
03 |
04 | uis.InputBegan:connect( function (input) |
05 | if input.KeyCode = = Enum.KeyCode.E then |
06 | charging = true |
07 | while charging = = true do |
08 | game.Players.LocalPlayer.Character.Humanoid.Mana.Value = game.Players.LocalPlayer.Character.Humanoid.Mana.Value + 1 |
09 | wait() |
10 | if charging = = false then return end |
11 | if game.Players.LocalPlayer.Character.Humanoid.Mana.Value = = 100 then return end |
12 | end |
13 | end |
14 | end ) |
15 |
16 | uis.InputEnded:connect( function (input) |
17 | if input.KeyCode = = Enum.KeyCode.E then |
18 | charging = false |
19 | end |
20 | end ) |