Why is my charging script breaking when it passes below 30?
i tried to make a script that reduces energy when you attack. I made it decreases if 30 and stops if the player has below 30 energy;but, when the energy goes below 30 it makes players not attack anymore, why?
02 | PunchEvent = game.Workspace.Attacks [ "Rico's Attacks" ] .Punch |
03 | replicatedstorage = game:GetService( "ReplicatedStorage" ) |
04 | staticball = replicatedstorage.RicoClass:findFirstChild( "Lightning" ) |
09 | tool.Selected:connect( function (mouse) |
10 | mouse.Button 1 Down:connect( function () |
14 | local player = game.Players.LocalPlayer |
16 | local Energy = player.PlayerGui.ScreenGui.TextButton.TextBox.EnergyValue |
17 | game:WaitForChild(player) |
19 | if Energy.Value > = 30 then |
20 | Energy.Value = Energy.Value - 30 |
23 | local player = game.Players.LocalPlayer |
24 | local Humanoid = player.Character.Humanoid |
26 | local Punch = Instance.new( "Animation" ) |
28 | local animTrack = Humanoid:LoadAnimation(Punch) |
29 | animTrack:Play( 0 , 2 , 2.5 ) |
31 | PunchEvent:FireServer(mouse.Hit) |