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

If statement not working correctly?

Asked by
wackem 50
9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.
local b = script.Parent
local guess = b.Parent.Guess
local nums = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}
local plr = b.Parent.Parent.Parent.Parent
local newNum = nums[math.random(1, #nums)]
local round = 1
local submitted = false
local val = 1

b.MouseButton1Click:connect(function()
submitted = true
    if guess.Text == newNum then
        b.Parent["Yes/No"].Text = "Correct!"
        plr.Guesses.Value = plr.Guesses.Value + val
    else
        b.Parent["Yes/No"].Text = "Incorrect!"
        plr.Fails.Value = plr.Fails.Value + val
    end
end)

if submitted == true then
    val = 0
end

while true do
    wait(15)
    round = round + 1
    newNum = nums[math.random(1, #nums)]
    print(newNum)
    val = 1
end

All of that works but if I try and stop the changing of the values if the submitted is true it doesn't work. Help?

So I want to, basically, after they click once they can't click again, but when a new round starts, they can.

0
I'm not sure where you're getting at. Where is the "if" statement you're concerned about at in the script overall? Is it within a code block? If so, can you post the code block? Redbullusa 1580 — 9y
0
its at the end of the post. wackem 50 — 9y
4
That's not what I mean. Where in your actual script is the "if" statement located? Redbullusa 1580 — 9y
0
^ It's not. Please post your entire code Perci1 4988 — 9y
View all comments (2 more)
0
You need to post the entire code, not just the if statement, so we know exactly where we're looking and what's causing the error. Spongocardo 1991 — 9y
0
the if statement provided at the end belongs on line 20, sorry. wackem 50 — 9y

Answer this question