Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

"Or" function in my script not doing the code under it, how to fix?

Asked by
Jirozu 71
7 years ago

So, to make this simple, this script is like a adding number script, but once it gets to the

1break end

then it stops and does the code below. But i have having some problems as once it gets to the

1or Charing == false then 

It doesnt print the code under below. Is there a simple fix for this?

01local Player = game.Players.LocalPlayer
02local Charge = 0
03local Charing = false
04local UIS = game:GetService("UserInputService")
05 
06UIS.InputBegan:connect(function(input)
07    if input.KeyCode ~= Enum.KeyCode.H then return end;
08    Charing = true
09    game:GetService("Chat"):Chat(Player.Character.Head, "HERE I GO...")
10    while Charing == true do
11        print(Charge)
12        Charge=Charge+1
13        if Charge == 120 or Charing == false then
14            print("aaa")
15            game:GetService("Chat"):Chat(Player.Character.Head, "HA!")
View all 25 lines...
0
When charing is set to false, the while loop will end and the if statement will never execute Programical 653 — 7y
0
How can i fix that? Jirozu 71 — 7y

1 answer

Log in to vote
-1
Answered by 7 years ago

You could ditch the or and just use an elseif statement instead:

01local Player = game.Players.LocalPlayer
02local Charge = 0
03local Charing = false
04local UIS = game:GetService("UserInputService")
05 
06UIS.InputBegan:connect(function(input)
07    if input.KeyCode ~= Enum.KeyCode.H then return end;
08    Charing = true
09    game:GetService("Chat"):Chat(Player.Character.Head, "HERE I GO...")
10    while Charing == true do
11        print(Charge)
12        Charge=Charge+1
13        if Charing == false then
14            print("aaa")
15            game:GetService("Chat"):Chat(Player.Character.Head, "HA!")
View all 29 lines...
Ad

Answer this question