Hello!
I wanna make a “Guess the word!” Type of game. But the script i made doesn’t work
the script is meant to do this: grab a random word, check if that word is put in the textbox and if it is make the text label with the chosen word visible
local words = {"banana","chocolate","bread","yogurth","food","ice cream"} -- The words
local label = script.Parent.TextLabel
local ChoosenWord = words[math.random(1,#words)] --The word that was chosen out of the words
local TextBox = script.Parent.TextBox
label.Text = ChoosenWord
print("The word is "..ChoosenWord.."!") --Prints the chossen word
if TextBox.Text == ChoosenWord then
label.Visible = true
end
Also, here how the screen gui looks
How could i make this work? Thanks in advance!
Is this what you mean?
Also, did you mean to put ChosenWord instead of ChoosenWord and chossen word?
if tostring(ChoosenWord) == script.Parent.TextBox.Text then
print("The word is "..ChoosenWord.."!")
end
just a typo haha, This isnt what i mean. I want to know if the chosen word is put on the textbox and make the textlabel visible. But that’s the part that doesn’t work. But thanks for the response!
Its happening under 1 sec. How could the Player put the correct Name into the Textbox if the word is choosen directly and is checking directly if the Text is in the Box.
local words = {"banana","chocolate","bread","yogurth","food","ice cream"} -- The words
local label = script.Parent.TextLabel
local TextBox = script.Parent.TextBox
Example.MouseButton1Click:Connect(function()
local ChoosenWord = words[math.random(1,#words)] --The word that was chosen out of the words
print("The word is "..ChoosenWord.."!") --Prints the chossen word
wait(10) -- Player has 10 sec to enter the correct Word.
if TextBox.Text == tostring(ChoosenWord) then
label.Visible = true
end
end)
A remind: This is the Client if u make this Work for all Players u should send RemoteEvents to the Server and make it there, if u dont know how to make it tell me
The Script is happening directly, the If Statement will not fire another Time.
1 Like
The script did not work… Thanks for the reply tho!
1 Like
That was a example, put this all in your Script, before add a TextButton and u are ready to go. After clicking the Button u have 20 sec Time to enter your answer.
local words = {"banana","chocolate","bread","yogurth","food","ice cream"} -- The words
local label = script.Parent.TextLabel
local TextBox = script.Parent.TextBox
script.Parent.TextButton.MouseButton1Click:Connect(function()
local ChoosenWord = words[math.random(1,#words)] --The word that was chosen out of the words
print("The word is "..ChoosenWord.."!") --Prints the chossen word
wait(20) -- Player has 10 sec to enter the correct Word.
if TextBox.Text == tostring(ChoosenWord) then
label.Visible = true
print("The Word is right")
end
end)
Thank you so much! it worked. (if you want to, i will credit you.)
1 Like
No problem and Thanks, u dont need to do it.