I'm trying to make it so the user can't dodge while charging their energy. And they can't because if they try it crashes. If I press E to dodge, and press F to charge energy before the dodge script ends, is where the problem occurs. If someone could help me make it where you can't dodge while charging I would appreciate it.
uis.InputBegan:connect(function(input)--Charge if input.KeyCode == Enum.KeyCode.F then charging = true while charging == true do if dodging == false then game.Players.LocalPlayer.Character.Humanoid.Mana.Value = game.Players.LocalPlayer.Character.Humanoid.Mana.Value + 1 wait() if charging == false then return end if game.Players.LocalPlayer.Character.Humanoid.Mana.Value > 100 then game.Players.LocalPlayer.Character.Humanoid.Mana.Value = 100 end end end end end) uis.InputEnded:connect(function(input)--Stop charging if input.KeyCode == Enum.KeyCode.F then charging = false end end) dodging = false uis.InputBegan:connect(function(input)--Dodge if input.KeyCode == Enum.KeyCode.E then if dodging == false then gg = Instance.new("BodyForce") gg.Parent = Player.Character.Torso gg.Force = Player.Character.Torso.CFrame.lookVector*-20000 Player.Character.Humanoid.Jump = true dodging = true wait(0.1) gg:Destroy() wait (1) dodging = false end end end)
Add Wait()
At line 4 . Everytime you do a loop add a wait() Or it will make an infinite loop and it will cause the game to crash.