- Home /
Question by
powerfoxgames · Apr 01, 2020 at 10:58 PM ·
c#uitext
if statement not working for user input
The code already recognises the user input and says it in text but it doesn't respond to if statements, anyone got any idea what's causing it to not work,
if (userInput == "James")
{ textComponent.text = "Sorry we already have someone named that";}
Edit: By the way theres also an else part and that works
else { textComponent.text = "Okay, That checks out.";}
Comment
Best Answer
Answer by GrayLightGames · Apr 02, 2020 at 05:03 AM
If userInput really holds the string "James", then the Sorry text should be displayed. Add Debug.Log("User Input is " + userInput);
right before your if statement and find out if it really has "James" in it. My guess is that userInput is not representing what you think it is. Log is your friend in finding out. Hope that helps!
Yep that's what was wrong I messed up the actual script, I fixed it now!