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:
local gui = script.Parent
local frame = gui.JournalFrame
local player = game.Players.LocalPlayer
local sound = script.Parent.JournalFrame.X.JournalCloseSound
local items = frame:GetChildren()
local Nouns = {"apple", "tree"}
local RemoteEvent = game.ReplicatedStorage.JournalEvent
local sound1 = frame.Success
local sound2 = frame.Book
local sound3 = frame.Error
for i, item in pairs(items) do
if item:IsA("GuiButton") and frame.Write.Text == Nouns[1] then -- This is the if statement
item.Activated:Connect(function()
local itemName = item.Name
game.ReplicatedStorage.JournalEvent:FireServer(itemName, game.Players.LocalPlayer:GetMouse().hit.Position)
player.PlayerGui.JournalGui.JournalFrame.Visible = false
player.PlayerGui.MiniJournalGui.MiniJournalFrame.Visible = true
player.PlayerGui.MiniJournalGui2.MiniJournalFrame2.Visible = false
player.PlayerGui.JournalGui.JournalBackFrame.Visible = false
player.PlayerGui.JournalGui.FailMessage.Visible = false
sound:Play()
wait(1)
game.Players.LocalPlayer:GetMouse().Button1Down:Connect(function()
end)
end)
elseif item:IsA("GuiButton") then
item.Activated:Connect(function()
gui.FailMessage.Visible = true
sound3:Play()
wait(4)
gui.FailMessage.Visible = false
local itemName = item.Name
end)
end
end
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?

1 comment
Thanks for the help it worked!