Like for example, in the picture below, I want to make it so that the word “If” would be highlighted after I press space (since my current word is free.)
How would I be able to do this? To find out what current player’s word is and then highlight it.
I thought of using string.match but some words like ‘he’ are going to be used repeated, so that sounds problematic.
words = {
"Hello",
"World.",
"How",
"Are",
"You?"
}
TextLabel:GetPropertyChangedSignal("Text"):Connect(function()
local text = TextLabel.Text
local splitText = text:split(" ")
local word = splitText[#splitText]
if word == words[#splitText] then
-- he did it right
else
-- fail
end
end)
If you keep track of what word they’re on from the start, you should be able to just increment that whenever they press space. Once you know what word they’re on, you can check if truncating that word gives what they’ve typed so far, and if so, do the green highlight effect.
Just create a table where you store correct and incorrect. Insert the start and end of every word and then get the start of the first word and the end of the last word. Then you know how much to highlight as correct and then for incorrect you can do the same but you just store one value instead of multiple ones.