Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to add more words for an if statement? [SOLVED]

Hello! I have this script that works but theres 1 problem.. i want to add more words like for example "Carrot" but if i add it next to the "Flamingo" search word it just like doesnt work..

local carrot = script.Parent.Parent.Carrot
local flam = script.Parent.Parent.Flamingo
local Glass = script.Parent.glass
local search = script.Parent.SearchBar
local mu = game.Workspace.MenuSound

--Search system
Glass.MouseButton1Click:Connect(function()
	if search.Text == "Flamingo" then
	flam.Visible = true
	else
	search.Text = "No results found.."
end
end)

Glass.MouseButton1Click:Connect(function()
	if search.Text == "Flamingo" then	
	mu.Volume = .20
	wait(.01)
	mu.Volume = .15
	wait(.01)
	mu.Volume = .10
	wait(.01)	
	mu.Volume = .05		
	wait(.01)
	wait(.01)	
	mu.Volume = 0		
	wait(.01)
	mu.Playing = false
	else
	mu.Playing = true
end
end)

Any Improvemnts or tips are welcome!

5 comments

0

you could say or search.Text == "Carrot" after the Flamingo, and put a then

0

but how bc it just doesnt work with a ,

0

you dont need a comma, you would just do if search.Text == "Flamingo" or search.Text == "Carrot" then

0

oo let me try it

0

ok so i think that works.. but now i need the word "Carrot" to make a other gui visible

1 answer

there is this magical thing called Elseif. What you can do is this

local carrot = script.Parent.Parent.Carrot
local flam = script.Parent.Parent.Flamingo
local Glass = script.Parent.glass
local search = script.Parent.SearchBar
local mu = game.Workspace.MenuSound

--Search system
Glass.MouseButton1Click:Connect(function()
    if search.Text == "Flamingo" then
    	flam.Visible = true
elseif search.Text == "Carrot" then
		Carrot.Visible = true		
	end
    else
    search.Text = "No results found.."
end
end)

Something like that im not sure what you want to do with carrot but use the concept

1 comment

0

You can also stack elseif meaning you can do multiple.

This discussion is preserved as it was. New answers, comments, and votes are closed.