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

How do I fix this?

Asked by 9 years ago

I have a game where you have to type words (just started today) and I want to make sure people type the word in order. I have them on separate TextLabels, and when they type the letter, it turns red So the first word is Type. (Note is some text on the screen saying to type them in order) Before they press t it is fine, but then after that or after you press y you can type e and p any way you want. Here is the code for one of the letters:

    if key == "p" then
        p.TextColor3 = Color3.new(235, 0, 0)
        if t.TextColor3 ~= Color3.new(235, 0, 0) then
            if y.TextColor3 ~= Color3.new(235, 0, 0) then
            p.TextColor3 = y.TextColor3
            for i = 1,10 do
                wait(0.1)
                Note.TextTransparency = Note.TextTransparency - 0.1
            end
            wait(1)
            for i = 1,10 do
                wait(0.1)
                Note.TextTransparency = Note.TextTransparency + 0.1
                end
            end
        end
    end

I tried many other things too!

2 answers

Log in to vote
0
Answered by 9 years ago

I don't know what Gui you're talking about, But i hope you figure it out.

Ad
Log in to vote
0
Answered by 9 years ago

(Note: Color3.new arguments should be between 0 and 1. If you have a number between 0 and 255, simply divide by 255; so, you should use this: Color3.new(235/255,0,0).)

You should consider what will happen if someone is typing faster than 1 character per 3 seconds -- your 'Note.TextTransparency" will start jumping all over the place as multiple coroutines attempt to modify it! You can either add Debounce, or stop running the loops if a new button is pressed.

Are you intending to hand craft each word (ie have a separate variable for each letter of each word)? That's a lot of work! You can save yourself a lot of time (at least in the long run) by learning how to use classes (or at least tables), letting you use the same code for all letters. You could then iterate over the current word (whatever that might be) and create a letter Gui for each one. Keep track of where they are in the word with a variable and you could make sure that they type each letter in order (if that's what you want; I can't quite tell).

Answer this question