Bug in my Hangman game

Here is a link to the app so far: Thunkable

I am creating a hangman game.
The app knows when you entered the right word by using a point system.
The amount of needed points to win for a word is equal to the amount of letters.
So: Program (7 Letters) means you need 7 Points.
If you would guess ‘‘r’’ you would get 2 points as the letter was in the word twice.
But this is the Bug:
If you now pressed ‘‘r’’ 2 times (so a second time after you guessed it right), it would give you too more points, meaning that if you press a letter that is correct enough times it will say you won. I tought about having a variable change to ‘‘used’’ so that i can do ‘‘if (’‘variable used?’’ = ‘‘used’’) show Alert (than have the alert say you already guessed the letter.) but because of my bad programming id have to put in this code for every correct letter i programmed so far. So far there are 2 words, both 6 letters. so id have to copy paste this script to 12 letters. And i am a bit lazy so i was wondering if there is an easier way. Also, i would like the incorrectly guessed letters to dissapear when guessed to avoid creation. But id have to do that for EVERY INCORRECT LETTER AGAIN BECAUSE OF MY D*MN BAD CODING D:… I have no idea if theres is a way to fix these things easily or if i should just start over with more efficient coding. Help appreciated!

that’s not the way hangman works - you can press a letter only once - if the letter is found in the secret word, all matching letters of the word should appear. pressing the same letter again should not do anything.
also, the winning condition should be , no more letters to guess (ie. you’ve guessed all the letters) and you haven’t used up the maximum number of guesses.

What you need to do is to copy the secret word to a variable. Then, use that variable when checking user input. If the user input matches letter(s) in the variable, remove the letter from the variable. Then, keep using that variable to check.


Secret word = BABY
Remaining letters = BABY

Guess = B
Remaining letters = AY

Guess = T
Remaining letters = AY

Guess = A
Remaining letters = Y


It’s difficult to remove a letter from a text string (I’ve requested that feature here). You can convert a text string to a list and then it’s easy to remove an item (letter) from the list.

An easier method might be to disable each button after it’s guessed. So if you guess B, that button has disabled set to true and then nothing happens if you click it again.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.