I have just moved on to another project. It is a friendly robot that you can talk to! I was making the script, when I was making an if statement to see if the player has written “hi”, “hello”, “Hello”, or “Hi” I wrote this, And it did not work.
--Script by TrackoTheTaco
--//Locals\\--
local Frame = script.Parent.Frame
local TextBox = script.Parent.Frame.TextBox
local SendBtn = script.Parent.Frame.TextButton
local player = game.Players.LocalPlayer
--//If the player clicks the Send Button\\--
SendBtn.MouseButton1Click:Connect(function()
if TextBox.Text == {"hi","hello","Hello","Hi"} then
TextBox.Text = "Hello! I'm Tralmo Bot! :D"
end
end)
I never saw a script like this. I suggest using this script
(there might be some errors, I am writing on mobile).
local Frame = script.Parent.Frame
local TextBox = script.Parent.Frame.TextBox
local SendBtn = script.Parent.Frame.TextButton
local player = game.Players.LocalPlayer
local function CheckForText (Text)
local words = {"hi","hello","Hello","Hi"}
local pass = false
for i,v in pairs (words) do
if v == Text then
pass = true
end
end
return pass
end
--//If the player clicks the Send Button\\--
SendBtn.MouseButton1Click:Connect(function()
if CheckForText(TextBox.Text) then
TextBox.Text = "Hello! I'm Tralmo Bot! :D"
end
end)
Basically, you can not compare a text input that easily to a table. That is why you should loop through the table.
You might also want to split the input, so you can compare each word with the table.
But when I make a new table, It will still say “Hello! I’m Tralmo Bot! :D” and It will not work with multiple tables because SendBtn.MouseButton1Click:Connect(function() if CheckForText(TextBox.Text) then TextBox.Text = "Hello! I’m Tralmo Bot! :D" end end)
does not mention the local: WIR (what is ROBLOX) that I created.
local Frame = script.Parent.Frame
local TextBox = script.Parent.Frame.TextBox
local SendBtn = script.Parent.Frame.TextButton
local player = game.Players.LocalPlayer
--//If the player clicks the Send Button\\--
SendBtn.MouseButton1Down:Connect(function()
if TextBox.Text == {"hi","hello","Hello","Hi"} then
TextBox.Text = "Hello! I'm Tralmo Bot! :D"
end
end)