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

Why doesn't my elseif statement doesn't work after "if val1 and val2 == 1 then"?

I've made this code


local value = 1


local val1 = 1


local val2 = 1


while true do

	if value == 1 then

		if val1 and val2 == 1 then

			print("yes")

		elseif value == 2 then

			if val1 and val2 == 1 then

				print("no")

			end

		end

	end

	wait(0.1)

end

when value = 1 it works fine, but when value = 2 it breaks and the elseif line doesn't recognize that the value = 2

2 comments

0

you realize the elseif is actually checking if this is false "val1 and val2 == true"

0

Put code in a code block for you

1 answer

✓ Accepted answer
local value = 1
local val1 = 1
local val2 = 1
while true do
	if value == 1 then
		if val1 == 1 and val2 == 1 then
			print("yes")
		end
		elseif value == 2 then
			val1 == 1 and val2 == 1 then
				print("no")
			end
		end
	end
end

whats wrong is that your script the elseif is actually testing if val1 and val2 doesn't equal 1

2 comments

0

You do not solve his problem. All you do is give him the code. You are supposed to tell him in debt what was his problem and how to fix it. I am posting my own awnser to his solution

0

in debt???? you mean in depth

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