If statement goes through when the options do not align

I have an if statement that should go to the else part of the block when they do not align, but for some reason, the if statement goes through no matter what

	if detector:GetAttribute("Straight") and nextstop[2] == straightsplit[1] or straightsplit[2] then
		print(nextstop, straightsplit)
		print("straight server")
		SwitchModule.Straight(straight, switch)
	else
		print("switch server")
		SwitchModule.Switch(straight, switch)
	end

image

can anyone help ? thanks !

its because of the or right here
image

so whatever things you wrote before it dont matter, because if straightsplit[2] exists then it will go through.

i think you meant to do something like this

if detector:GetAttribute("Straight") and( nextstop[2] == straightsplit[1] or nextstop[2] ==  straightsplit[2]) then

see how i use brackets?

1 Like

didnt know you had to seperate it with brackets, learning as I go along :grin: thanks for the help !

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.