Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to detect a certain ASCII character and press a GUI button?

Ok, I need some help.

You see, I'm making a Roblox piano autoplayer for a game I'm making (Virtual Piano-style game.)

Basically, what I'm wanting to do is:

  1. A player inserts their Virtual Piano notes into a TextBox
  2. They press a button
  3. A script repeatedly detects a whitespace and a character, and depending on the character it'll press a GUI button on the Piano GUI.

If it isn't possible to make a player automatically click a GUI button (and someone knows how the pianos work), how can I make the player click a key on the piano?

-2048EE

1 answer

Your question is a little confusing but to achieve what you’re asking, you can use string.find or string.match.

You seem to want to check multiple matches so you might use string.gmatch instead.

To detect whitespace, you use the pattern “%s” and to detect non-whitespace, you can use “^[%s]”

for matched in string.gmatch(text, “^[%s]”) do
    --your code, you can compare what matched is.
end

You can replace “^[%s]” with “^[%s]+” for matching multiple non-whitespace at a time until you find whitespace then repeat. (+ indicates matching more than 1, [] is for a set, %s is whitespace, ^ means any opposite of the pattern given in front of it).

For the part you ask about automatic button pressing, if it is a GUI button, I don’t think there’s a way so the function connected to the clicking event you’d just fire instead to do the automatic stuff.

This discussion is preserved as it was. New answers, comments, and votes are closed.