Something simple isn't working?

function checkRoom(player, room)
	print(room)
	if room == "Room1" then
		print("room one")
		wait(3)
	elseif room == "Room2" then
		print("room two")
		wait(3)
	else
		warn("Could not find this room.")
	end
end

It gives the ‘room’ argument either Room1 or Room2 and it’s even confirmed when it prints it but for some reason the if statements don’t work? It prints the warning message.

Make sure that player isn’t the room value and room value isn’t nil

checkRoom(player, room) -- Make sure that player is player and room is room not player is room and room is nil

Don’t understand the point behind it, still doesn’t work
print(player) prints the player name
print(room) prints Room1 or Room2
I don’t see what wrong.

This is actually weird I’m not sure if the room variable implemented within your code is a string. Try this instead.

function checkRoom(player, room)
	print(room)
	if tostring(room) == "Room1" then
		print("room one")
		wait(3)
	elseif tostring(room) == "Room2" then
		print("room two")
		wait(3)
	else
		warn("Could not find this room.")
	end
end
1 Like

It worked, thank you so much I guess I need to do some thinking xD

1 Like

Print the arguments passed in the function using:

print(room)

If it is nil or not “Room1” or “Room2” then you are not passing the correct arguments.