Why is the if statement I made not working?
Asked by
2 years ago Edited 2 years ago
I wrote an if statement that is supposed to make a model appear if someone types the correct word into a textbox and presses the enter button:
01 | local gui = script.Parent |
02 | local frame = gui.JournalFrame |
03 | local player = game.Players.LocalPlayer |
04 | local sound = script.Parent.JournalFrame.X.JournalCloseSound |
05 | local items = frame:GetChildren() |
06 | local Nouns = { "apple" , "tree" } |
07 | local RemoteEvent = game.ReplicatedStorage.JournalEvent |
08 | local sound 1 = frame.Success |
09 | local sound 2 = frame.Book |
10 | local sound 3 = frame.Error |
12 | for i, item in pairs (items) do |
13 | if item:IsA( "GuiButton" ) and frame.Write.Text = = Nouns [ 1 ] then |
14 | item.Activated:Connect( function () |
15 | local itemName = item.Name |
16 | game.ReplicatedStorage.JournalEvent:FireServer(itemName, game.Players.LocalPlayer:GetMouse().hit.Position) |
17 | player.PlayerGui.JournalGui.JournalFrame.Visible = false |
18 | player.PlayerGui.MiniJournalGui.MiniJournalFrame.Visible = true |
19 | player.PlayerGui.MiniJournalGui 2. MiniJournalFrame 2. Visible = false |
20 | player.PlayerGui.JournalGui.JournalBackFrame.Visible = false |
21 | player.PlayerGui.JournalGui.FailMessage.Visible = false |
24 | game.Players.LocalPlayer:GetMouse().Button 1 Down:Connect( function () |
27 | elseif item:IsA( "GuiButton" ) then |
28 | item.Activated:Connect( function () |
29 | gui.FailMessage.Visible = true |
32 | gui.FailMessage.Visible = false |
33 | local itemName = item.Name |
When the person types "apple" into the textbox (named Write) and presses the enter button, it is supposed to spawn in the model, and if they write anything else and press enter, it is supposed to display the fail message, but even if they write "apple" it displays the fail message, why does this happen?